Open
Description
#define A 2
int b[A];
// make b unchecked
// void* unc(void) { return b; }
int* foo(void) {
return b;
}
converts to
#define A 2
int b _Checked[2];
// make b unchecked
// void* unc(void) { return b; }
_Array_ptr<int> foo(void) : count(2) {
return b;
}
remove the comment to make b wild and we get
#define A 2
int b[A];
// make b unchecked
void* unc(void) { return b; }
int *foo(void) : itype(_Array_ptr<int>) count(2) {
return b;
}
In-lining a macro and using it as a bounds is unfortunate, but at least in the first conversion it is consistent. b
becomes an array of 2 elements and so foo
returns an array of 2 elements. In the second conversion, b is not rewritten, but internally bound to 2 elements. This bound shows up later when foo
still returns (tries to? will eventually? what is the interpretation of a return itype?) an array of 2 elements.
Perhaps this bound should be removed? It may be very confusing to people to see, or miss, a number showing up like this in the conversion. And it could cause bugs if they don't remove it before changing A
, which could be anywhere in the project.