https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108036

--- Comment #15 from Alejandro Colomar <[email protected]> ---
This triggers even with [[gnu::access(none, N)]], which supposedly tells the
compiler there's absolutely no access (i.e., a pointer with zero elements, as
returned from malloc(0) should be perfectly valid).


alx@devuan:~/tmp$ cat foo.c 
#define endof(a)  (&(a)[_Countof(a)])

[[gnu::access(none, 2)]] void f(int p[], int e[0]);

int
main(void)
{
        int  a[42];
        int  *p, *e;

        p = a;
        e = endof(a);
        f(p, e);
}
alx@devuan:~/tmp$ gcc-16 -Wall -Wextra -S foo.c 
foo.c: In function ‘main’:
foo.c:13:9: warning: ‘f’ accessing 4 bytes in a region of size 0
[-Wstringop-overflow=]
   13 |         f(p, e);
      |         ^~~~~~~
foo.c:13:9: note: referencing argument 2 of type ‘int[0]’
foo.c:3:31: note: in a call to function ‘f’
    3 | [[gnu::access(none, 2)]] void f(int p[], int e[0]);
      |                               ^

Reply via email to