Open
Description
The spec allows us to take the address of a checked pointer with unknown bounds.
However, explicitly annotating a pointer with bounds(unknown)
and then taking its address trigger a compiler error:
int main() {
_Array_ptr<int> p : bounds(unknown);
(void)&p;
return 0;
}
test1.c:3:12: error: cannot take address of variable 'p' with bounds
(void)&p;
^
test1.c:2:25: note: bounds declared here
_Array_ptr<int> p : bounds(unknown);
^~~~~~~~~~~~~~~
1 error generated.
There is no error if p
is declared without bounds annotation:
int main() {
_Array_ptr<int> p;
(void)&p;
return 0;
}
But p
has unknown bounds by default in the above snippet. It's surprising that adding a redundant bounds(unknown)
annotation causes the compiler to reject the code.