https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121547
Bug ID: 121547
Summary: -Warray-bounds= has has interferences with -Wall for
the trigger
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
alx@devuan:~/tmp$ cat callee.c | nl -ba
1 void f(int a[6]);
2
3 void
4 f(int a[6])
5 {
6 a[42] = 1;
7 }
alx@devuan:~/tmp$ gcc -S -Wall -O2 callee.c
callee.c: In function ‘f’:
callee.c:6:10: warning: array subscript 42 is outside array bounds of ‘int[6]’
[-Warray-bounds=]
6 | a[42] = 1;
| ~^~~~
callee.c:4:7: note: at offset 168 into object ‘a’ of size [0, 24]
4 | f(int a[6])
| ~~~~^~~~
alx@devuan:~/tmp$ gcc -S -Warray-bounds=2 -O2 callee.c
alx@devuan:~/tmp$
For some reason, -Warray-bounds=2 doesn't trigger itself, but -Wall does. Am I
missing something?