arocc
arocc copied to clipboard
Incorrect attribute application for nested pointers
This should be a single pointer to a single pointer, but the attribute gets applied twice to the outer pointer:
#include <ptrcheck.h>
void foo(int *__single *__single p) {
p[0][5] = 5;
}
% arocc -fexperimental-bounds-safety test.c
test.c:3:25: warning: pointer annotated with single multiple times. Annotate only once to remove this warning [-Wbounds-attributes-redundant]
void foo(int *__single *__single p) {
^
/Users/ehaas/source/arocc/zig-out/include/ptrcheck.h:11:33: note: expanded from here
#define __single __attribute__((__single__))
^
% clang -Xclang -fexperimental-bounds-safety test.c
test.c:4:6: error: array subscript on single pointer 'p[0]' must use a constant index of 0 to be in bounds
4 | p[0][5] = 5;
| ~~~~^~
1 error generated.