Optimization levels for getting all warnings (was: [BUG] missing warning for pointer arithmetic out of bounds)

2022-12-18 Thread Alejandro Colomar via Gcc
Hi Andrew On 12/13/22 20:18, Andrew Pinski wrote: [...] GCC only warns during VRP which is only enabled at -O2: :8:12: warning: array subscript 6 is outside array bounds of 'char[5]' [-Warray-bounds=] 8 | p = buf + 6; | ~~^ :6:19: note: at offset 6 into o

Re: [BUG] missing warning for pointer arithmetic out of bounds

2022-12-13 Thread Jonathan Wakely via Gcc
On Tue, 13 Dec 2022, 19:23 Paul Koning via Gcc, wrote: > > > > > On Dec 13, 2022, at 2:08 PM, Alejandro Colomar via Gcc > > wrote: > > > > Hi! > > > > For the following program: > > > > > >$ cat buf.c > >#include > > > >int main(void) > >{ > >char *p, buf[5]; > > > >

Re: [BUG] missing warning for pointer arithmetic out of bounds

2022-12-13 Thread Alejandro Colomar via Gcc
Hi Paul, On 12/13/22 20:22, Paul Koning wrote: On Dec 13, 2022, at 2:08 PM, Alejandro Colomar via Gcc wrote: Hi! For the following program: $ cat buf.c #include int main(void) { char *p, buf[5]; p = buf + 6; printf("%p\n", p); } There are

Re: [BUG] missing warning for pointer arithmetic out of bounds

2022-12-13 Thread Paul Koning via Gcc
> On Dec 13, 2022, at 2:08 PM, Alejandro Colomar via Gcc > wrote: > > Hi! > > For the following program: > > >$ cat buf.c >#include > >int main(void) >{ >char *p, buf[5]; > >p = buf + 6; >printf("%p\n", p); >} > > > There are no warnings in

Re: [BUG] missing warning for pointer arithmetic out of bounds

2022-12-13 Thread David Malcolm via Gcc
On Tue, 2022-12-13 at 20:15 +0100, Alejandro Colomar via Gcc wrote: > > > On 12/13/22 20:08, Alejandro Colomar wrote: > > Hi! > > > > For the following program: > > > > > > $ cat buf.c > > #include > > > > int main(void) > > { > > char *p, buf[5]; > > > >   

Re: [BUG] missing warning for pointer arithmetic out of bounds

2022-12-13 Thread Andrew Pinski via Gcc
On Tue, Dec 13, 2022 at 11:16 AM Alejandro Colomar via Gcc wrote: > > > > On 12/13/22 20:08, Alejandro Colomar wrote: > > Hi! > > > > For the following program: > > > > > > $ cat buf.c > > #include > > > > int main(void) > > { > > char *p, buf[5]; > > > > p =

Re: [BUG] missing warning for pointer arithmetic out of bounds

2022-12-13 Thread Alejandro Colomar via Gcc
On 12/13/22 20:08, Alejandro Colomar wrote: Hi! For the following program:     $ cat buf.c     #include     int main(void)     {     char *p, buf[5];     p = buf + 6;     printf("%p\n", p);     } There are no warnings in gcc, as I would expect: I just re-read my te

[BUG] missing warning for pointer arithmetic out of bounds

2022-12-13 Thread Alejandro Colomar via Gcc
Hi! For the following program: $ cat buf.c #include int main(void) { char *p, buf[5]; p = buf + 6; printf("%p\n", p); } There are no warnings in gcc, as I would expect: $ gcc -Wall -Wextra buf.c -O0 Clang does warn, however: $ clang -W