checkedc icon indicating copy to clipboard operation
checkedc copied to clipboard

Broaden inference of interop types and bounds expressions

Open dtarditi opened this issue 6 years ago • 0 comments

Given an interop type, the compiler will now infer a bounds expression if the type is an nt_array_ptr or an array. The spec needs to be updated to describe this.

Also, I noticed that for local variables and global variables with unchecked array types, we should infer an interop type if none is specified. Given this code,

int global_arr[5];

_Checked int f(void) {
    _Ptr<int> p = global_arr;
}

the compiler complained that global_arr needed an interop type:

D:\checkedc1\llvm\tools\clang\test\CheckedC>%clang% -c test1.c
test1.c:4:19: error: global variable used in a checked scope must have a checked type or a bounds-safe interface
    _Ptr<int> p = global_arr;

dtarditi avatar Mar 22 '18 20:03 dtarditi