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
-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]
> >
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
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)
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
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
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;
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
--
<
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
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
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
11 matches
Mail list logo