This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ipa/66424] New: wrong code at -O2 and -O3 on x86_64-linux-gnu in 32-bit mode


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

            Bug ID: 66424
           Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu in
                    32-bit mode
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

The current gcc trunk (and 5.1.x) miscompiles the following code on
x86_64-linux at -O2 and -O3 in 32-bit mode (but not in 64-bit mode).  

This is a regression from 4.9.x.


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 6.0.0 20150604 (experimental) [trunk revision 224114] (GCC) 
$ 
$ gcc-trunk -m32 -Os small.c; ./a.out
small.c: In function âfn1â:
small.c:7:1: warning: type of âpâ defaults to âintâ [-Wimplicit-int]
 fn1 (p)
 ^
$ gcc-trunk -m64 -O2 small.c; ./a.out
small.c: In function âfn1â:
small.c:7:1: warning: type of âpâ defaults to âintâ [-Wimplicit-int]
 fn1 (p)
 ^
$ gcc-4.9.2 -m32 -O2 small.c; ./a.out
$ 
$ gcc-trunk -m32 -O2 small.c
small.c: In function âfn1â:
small.c:7:1: warning: type of âpâ defaults to âintâ [-Wimplicit-int]
 fn1 (p)
 ^
$ ./a.out
Aborted (core dumped)
$ 


---------------------------------------


int a, b, c, d, e[2], f, l, m, n, o;
long long g = 1, j;
static unsigned int h;
static int i, k;

void
fn1 (p)
{
  f = 1 ^ e[f ^ (p & 1)];
}

static void
fn2 (long long p)
{
  f = 1 ^ e[(f ^ 1) & 1];
  fn1 (p >> 1 & 1);
  fn1 (p >> 32 & 1);
}

void
fn3 (int p)
{
  g |= j = p;
}

int
main ()
{
  e[0] = 1;
  char p = l;
  h = --g;
  i = o = c;
  m = d ? 1 / d : 0;
  fn3 (l || 0);
  b = a;
  n = j++;
  k--;
  fn2 (g);
  fn2 (h);
  fn2 (i);

  if (k + f)
    __builtin_abort ();

  return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]