public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/57359] New: wrong code for union access at -O3 on x86_64-linux
@ 2013-05-21 18:20 dhazeghi at yahoo dot com
  2013-05-21 18:26 ` [Bug rtl-optimization/57359] " pinskia at gcc dot gnu.org
                   ` (31 more replies)
  0 siblings, 32 replies; 33+ messages in thread
From: dhazeghi at yahoo dot com @ 2013-05-21 18:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57359
           Summary: wrong code for union access at -O3 on x86_64-linux
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhazeghi at yahoo dot com

The following code is miscompiled with current gcc 4.8 branch and trunk at -O3
on x86_64-linux.  The last write to the union appears to be getting removed (*k
= 0), so that the program outputs '1' instead of '0'.  This behavior does not
occur on 4.7.

$ gcc-trunk -v
gcc version 4.9.0 20130521 (experimental) [trunk revision 199148] (GCC) 
$ gcc-trunk -O2 wrong.c 
$ ./a.out 
0
$ gcc-4.7 -O3 wrong.c 
$ ./a.out 
0
$ gcc-trunk -O3 wrong.c 
$ ./a.out 
1
$
-------------------------------
int printf(const char *, ...);

union
{
    int i;
    long long ll;
} u;

unsigned int i;

int a;
int *pa = &a;
int **ppa = &pa;
int ia[1][1];

long long *la[][1][1] = { {}, {}, {}, {}, 0, &u.ll };
long long **ppll = &la[4][1][0];
long long ll = 1;

void
foo ()
{
    for (; i <= 1; i++)
    {
        int *j;
        int *k = &u.i;
        **ppll = ll;
        *k = 0;
        j = *ppa;
        ia[0][0] = *j;
    }
}

int
main ()
{
    foo ();
    printf ("%d\n", u.i);
    return 0;
}


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

end of thread, other threads:[~2020-06-11 15:55 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21 18:20 [Bug rtl-optimization/57359] New: wrong code for union access at -O3 on x86_64-linux dhazeghi at yahoo dot com
2013-05-21 18:26 ` [Bug rtl-optimization/57359] " pinskia at gcc dot gnu.org
2013-05-21 18:33 ` jakub at gcc dot gnu.org
2013-05-23 19:51 ` dhazeghi at yahoo dot com
2013-05-29 21:14 ` dhazeghi at yahoo dot com
2013-05-30  7:13 ` jakub at gcc dot gnu.org
2013-05-31  8:48 ` rguenth at gcc dot gnu.org
2013-05-31 16:32 ` dhazeghi at yahoo dot com
2013-05-31 21:07 ` joseph at codesourcery dot com
2013-06-03 19:15 ` dhazeghi at yahoo dot com
2013-06-04 12:37 ` [Bug tree-optimization/57359] " rguenth at gcc dot gnu.org
2020-04-20  7:15 ` [Bug tree-optimization/57359] store motion causes wrong code for union access at -O3 rguenth at gcc dot gnu.org
2020-04-20  8:57 ` rguenth at gcc dot gnu.org
2020-04-20 10:50 ` rguenth at gcc dot gnu.org
2020-04-20 12:03 ` rguenth at gcc dot gnu.org
2020-04-20 12:34 ` pascal_cuoq at hotmail dot com
2020-04-20 12:39 ` rguenther at suse dot de
2020-04-21  7:22 ` rguenth at gcc dot gnu.org
2020-04-27  9:17 ` rguenth at gcc dot gnu.org
2020-04-27  9:35 ` rguenth at gcc dot gnu.org
2020-04-27 12:48 ` rguenth at gcc dot gnu.org
2020-04-30 12:25 ` rguenth at gcc dot gnu.org
2020-05-07 10:12 ` cvs-commit at gcc dot gnu.org
2020-05-07 10:13 ` rguenth at gcc dot gnu.org
2020-05-11 12:56 ` rguenth at gcc dot gnu.org
2020-05-11 12:56 ` rguenth at gcc dot gnu.org
2020-05-11 14:53 ` rguenth at gcc dot gnu.org
2020-05-11 14:57 ` rguenth at gcc dot gnu.org
2020-05-12  6:26 ` rguenth at gcc dot gnu.org
2020-05-12 11:53 ` ro at gcc dot gnu.org
2020-05-12 12:13 ` rguenth at gcc dot gnu.org
2020-05-18  9:50 ` rguenth at gcc dot gnu.org
2020-06-11 15:55 ` 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).