[Bug tree-optimization/61502] == comparison on "one-past" pointer gives wrong result
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jul 3 18:34:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61502
--- Comment #20 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Alexander Cherepanov from comment #19)
> (In reply to joseph@codesourcery.com from comment #3)
> > Except within a larger object, I'm not aware of any reason the cases of
> > two objects following or not following each other in memory must be
> > mutually exclusive.
>
> Apparently some folks use linker scripts to get a specific arrangement of
> objects.
>
> A fresh example is a problem in Linux -- https://lkml.org/lkml/2016/6/25/77
> . A simplified example from http://pastebin.com/4Qc6pUAA :
>
> extern int __start[];
> extern int __end[];
>
> extern void bar(int *);
>
> void foo()
> {
> for (int *x = __start; x != __end; ++x)
> bar(x);
> }
To get around the above example:
extern int __start[];
extern int __end[];
extern void bar(int *);
void foo()
{
int *x = __start;
int *y = __end;
asm("":"+r"(x));
asm("":"+r"(y));
for (; x != y; ++x)
bar(x);
}
>
> This is optimized into an infinite loop by gcc 7 at -O.
More information about the Gcc-bugs
mailing list