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
-Wextra buf.c -O0 > > > > Clang does warn, however: > > > >$ clang -Weverything -Wall -Wextra buf.c -O0 > >buf.c:8:17: warning: format specifies type 'void *' but the argument has > > type 'char *' [-Wformat-pedantic] > >

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

2022-12-13 Thread Alejandro Colomar via Gcc
ntic] printf("%p\n", p); ~~ ^ %s buf.c:7:6: warning: the pointer incremented by 6 refers past the end of the array (that contains 5 elements) [-Warray-bounds-pointer-arithmetic] p = buf + 6; ^ ~ I thought void * is a generic p

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

2022-12-13 Thread Paul Koning via Gcc
e 'void *' but the argument has > type 'char *' [-Wformat-pedantic] >printf("%p\n", p); >~~ ^ >%s > buf.c:7:6: warning: the pointer incremented by 6 refers past the end of > the array (that contains 5 elements)

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

2022-12-13 Thread David Malcolm via Gcc
gument has > > type 'char *' [-Wformat-pedantic] > >      printf("%p\n", p); > > ~~ ^ > > %s > > buf.c:7:6: warning: the pointer incremented by 6 refers past > > the end of the > > a

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

2022-12-13 Thread Andrew Pinski via Gcc
buf.c:8:17: warning: format specifies type 'void *' but the argument > > has > > type 'char *' [-Wformat-pedantic] > > printf("%p\n", p); > > ~~ ^ > > %s > > buf.c:7:6: war

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

2022-12-13 Thread Alejandro Colomar via Gcc
har *' [-Wformat-pedantic]     printf("%p\n", p);     ~~ ^     %s     buf.c:7:6: warning: the pointer incremented by 6 refers past the end of the array (that contains 5 elements) [-Warray-bounds-pointer-arithmetic]     p = buf + 6;    

[BUG] missing warning for pointer arithmetic out of bounds

2022-12-13 Thread Alejandro Colomar via Gcc
remented by 6 refers past the end of the array (that contains 5 elements) [-Warray-bounds-pointer-arithmetic] p = buf + 6; ^ ~ buf.c:5:2: note: array 'buf' declared here char *p, buf[5]; ^ 2 warnings generated. Cheers, Alex -- <

Re: Pointer arithmetic

2013-08-07 Thread Hendrik Greving
Yes I guess otherwise you could never produce a complex address like that. Actually I think I remember that day that I found that C explicitly leaves it undefined and to the machine. Thanks Hendrik On Wed, Aug 7, 2013 at 1:40 PM, Oleg Endo wrote: > On Tue, 2013-07-09 at 09:37 -0700, Hendrik Grevi

Re: Pointer arithmetic

2013-08-07 Thread Oleg Endo
On Tue, 2013-07-09 at 09:37 -0700, Hendrik Greving wrote: > On a machine with ABI ILP32LL64: > > (insn 123 122 124 (nil) (set (reg:SI 392) > (mem:SI (plus:SI (reg/v:SI 386) > (reg/v:SI 349)) [0 sec 0 space 0, cmsmode 0 S4 A32])) -1 (nil) > (nil)) > > If we support legi

Pointer arithmetic

2013-07-09 Thread Hendrik Greving
On a machine with ABI ILP32LL64: (insn 123 122 124 (nil) (set (reg:SI 392) (mem:SI (plus:SI (reg/v:SI 386) (reg/v:SI 349)) [0 sec 0 space 0, cmsmode 0 S4 A32])) -1 (nil) (nil)) If we support legitimate memory addresses like [r1+r2] (e.g. indexed addresses), can the abo