public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/56576] New: wrong code for aliased union at -O3
@ 2013-03-09  1:54 dhazeghi at yahoo dot com
  2013-03-09  8:26 ` [Bug tree-optimization/56576] " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dhazeghi at yahoo dot com @ 2013-03-09  1:54 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56576

             Bug #: 56576
           Summary: wrong code for aliased union at -O3
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dhazeghi@yahoo.com


The following code behaves differently at -O3 than at -O2 or below on 4.7 and
mainline on x86_64-linux.  At -O3 it returns 1, whereas at -O2 and below it
returns 0, for both -m32 and -m64 targets.

It behaves as expected on gcc 4.6 at all optimization levels (returns 0).

$ gcc-trunk --version
gcc-trunk (GCC) 4.8.0 20130308 (experimental) [trunk revision 196555]
$ gcc-trunk -O2 trans-reduced.c 
$ ./a.out 
$ echo $?
0
$ gcc-trunk -O3 trans-reduced.c 
$ ./a.out 
$ echo $?
1
$ gcc-4.6 -O3 trans-reduced.c 
$ ./a.out 
$ echo $?
0
$ cat trans-reduced.c 

/* gcc-4.7/gcc-trunk -O3 -m32/-m64 */
union
{
    int f0;
    int f1;
    long f2;
}
a, b;
int c, h;
int *d, *e = &a.f0;
long *f = &b.f2;
int **g = &d;
void fn1 ()
{
    c = 0;
    for (; c <= 3; c++)
    {
        int *i = &b.f1;
        *f = 1;
        *i = 0;
        *g = 0;
        h = *e;
    }
}

int main ()
{
    fn1 ();
    return b.f0;
}


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-02 16:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-09  1:54 [Bug tree-optimization/56576] New: wrong code for aliased union at -O3 dhazeghi at yahoo dot com
2013-03-09  8:26 ` [Bug tree-optimization/56576] " jakub at gcc dot gnu.org
2013-03-10 21:17 ` pinskia at gcc dot gnu.org
2024-06-02 16:10 ` pinskia at gcc dot gnu.org
2024-06-02 16:11 ` pinskia at gcc dot gnu.org
2024-06-02 16:12 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).