public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/57303] New: struct miscompiled at -O1 and above
@ 2013-05-16 15:59 dhazeghi at yahoo dot com
  2013-05-16 16:18 ` [Bug tree-optimization/57303] " glisse at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: dhazeghi at yahoo dot com @ 2013-05-16 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57303
           Summary: struct miscompiled at -O1 and above
           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

With current gcc trunk, the code below is miscompiled at -O1 and higher
optimization levels on x86_64-linux-gnu, outputting '1' instead of '0' as
expected.  This behavior appears in gcc 4.8.x and 4.7.x as well, but not in
4.6.x or earlier.  It occurs in both 32-bit and 64-bit compiles.

$ gcc-trunk -v
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-checking
--with-gmp=/usr/local/gcc-trunk --with-mpfr=/usr/local/gcc-trunk
--with-mpc=/usr/local/gcc-trunk --with-cloog=/usr/local/gcc-trunk
--prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20130516 (experimental) [trunk revision 198967] (GCC) 
$ gcc-trunk -O0 small.c
$ ./a.out 
0
$ gcc-4.6 -O1 small.c
$ ./a.out 
0
$ gcc-trunk -O1 small.c
$ ./a.out 
1
$
-----------------------------

int printf(const char *, ...);

struct S0
{
    int f0;
};
struct S1
{
    struct S0 f0;
};

struct S1 x = { {0} };
struct S1 y = { {1} };

static void
foo (struct S0 p)
{
    struct S0 *l = &y.f0;
    *l = x.f0;
    if (p.f0)
        *l = *l;
}

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


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

end of thread, other threads:[~2014-03-17 14:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-16 15:59 [Bug rtl-optimization/57303] New: struct miscompiled at -O1 and above dhazeghi at yahoo dot com
2013-05-16 16:18 ` [Bug tree-optimization/57303] " glisse at gcc dot gnu.org
2013-05-17  8:44 ` [Bug tree-optimization/57303] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-05-17  9:05 ` rguenth at gcc dot gnu.org
2013-05-20 16:05 ` glisse at gcc dot gnu.org
2013-05-21  7:57 ` rguenther at suse dot de
2013-05-21  8:38 ` [Bug tree-optimization/57303] [4.7/4.8 " rguenth at gcc dot gnu.org
2013-05-21 14:00 ` glisse at gcc dot gnu.org
2013-05-22  8:08 ` [Bug tree-optimization/57303] [4.7 " rguenth at gcc dot gnu.org
2014-03-17 14:39 ` rguenth at gcc dot gnu.org
2014-03-17 14:39 ` rguenth 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).