[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#382290: gcc-4.1: O2 optimization problem



Package: gcc-4.1
Version: 4.1.1-10
Severity: normal

The following C code works fine with -O0 or -O1 but does not work
correct with -O2

#include <stdio.h>

void foo (int arg1)
{
        int loc1;

        if (arg1 < 0) {
                        loc1 = -arg1;
                        printf ("%d\n", loc1 == ((int) 0x80000000L));
        }
}

int main ()
{
        foo ((int) 0x80000000L);

        return 0;
}

The expected result is that 1 is printed.

I tested the same thing on a 32bit machine as well and it has the same
problem.

Regards,
Patrick

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-2-amd64-k8
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages gcc-4.1 depends on:
ii  binutils                      2.17-2     The GNU assembler, linker and bina
ii  cpp-4.1                       4.1.1-10   The GNU C preprocessor
ii  gcc-4.1-base                  4.1.1-10   The GNU Compiler Collection (base 
ii  libc6                         2.3.6-19   GNU C Library: Shared libraries
ii  libgcc1                       1:4.1.1-10 GCC support library
ii  libssp0                       4.1.1-10   GCC stack smashing protection libr

Versions of packages gcc-4.1 recommends:
ii  libc6-dev                     2.3.6-19   GNU C Library: Development Librari
pn  libmudflap0-dev               <none>     (no description available)

-- no debconf information



Reply to: