[Bug tree-optimization/69355] [5 Regression] Wrong results with -O1 optimization

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 26 14:33:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69355

--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Martin Jambor from comment #19)
> Because the reduced testcase from comment #10 does not fail for me (on
> revision 232662), I have tried to use creduce myself but have never
> ended up with anything useful (I got source with undefined behavior
> that would be passing and failing on different x86_64 machines).

Strange.

> whether we actually want it in the testcase (perhaps with
> -fno-strict-aliasing as a QoI test?).

With -fno-strict-aliasing it should be (as a GNU extension) well defined.
Guess you want to return 0 early in main if sizeof (long double) < sizeof
(struct Z); and probably also use long long instead of long field in struct Z.

> struct S
> {
>   void *a;
>   long double b;
> };
> 
> struct Z
> {
>   long l;
>   short s;
> } __attribute__((packed));
> 
> struct S __attribute__((noclone, noinline))
> foo (void *v, struct Z *z)
> {
>   struct S t;
>   t.a = v;
>   *(struct Z *) &t.b = *z;
>   return t;
> }
> 
> struct Z gz;
> 
> int
> main (int argc, char **argv)
> {
>   struct S s;
> 
>   gz.l = 0xbeef;
>   gz.s = 0xab;
> 
>   s = foo ((void *) 0, &gz);
> 
>   if ((((struct Z *) &s.b)->l != gz.l)
>       || (((struct Z *) &s.b)->s != gz.s))
>     __builtin_abort ();
>   return 0;
> }


More information about the Gcc-bugs mailing list