https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109590
--- Comment #5 from Jonny Grant <jg at jguk dot org> --- (In reply to Xi Ruoyao from comment #4) > (In reply to Jonny Grant from comment #2) > > (In reply to Andrew Pinski from comment #1) > > > There is -Wnull-dereference for this ... > > > > I agree. I set that -Wnull-dereference in usual projects (it doesn't seem to > > get enabled by -Wall -Wextra) > > > > I just expected -Warray-bounds to get the 0x0 address too > > There is no reason to expect this. There is no array at 0x0 address. The > warning for *p in your case is already complained as false warning in > another PR (I cannot remember the number, but I'm sure there is such a PR). I get what you are saying, it's a pointer, not a zero-length array that -Warray-bounds is designed to detect. I tried these two, just for completeness. n[0] no warning, n[1] gives warning https://godbolt.org/z/q4fbTofqM https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html This is another C example, with a struct, like the manual describes, but no warning -O2 -Wall -Warray-bounds=2 -std=c2x https://godbolt.org/z/W1G3Wrnoh #include <stddef.h> typedef struct foo { char buf[0]; } foo_t; int main() { foo_t * n = NULL; return n->buf[1]; } https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html I did wonder what 'this_length' refers to in that example