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

Bug#382290: marked as done (gcc-4.1: O2 optimization problem)



Your message dated Thu, 10 Aug 2006 07:09:57 +0200
with message-id <20060810050957.GA21920@wavehammer.waldi.eu.org>
and subject line Bug#382290: gcc-4.1: O2 optimization problem
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
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


--- End Message ---
--- Begin Message ---
On Wed, Aug 09, 2006 at 05:59:05PM -0700, Patrick Ruckstuhl wrote:
> The following C code works fine with -O0 or -O1 but does not work
> correct with -O2

> void foo (int arg1)
> {
>         int loc1;

signed, so no defined overflow behaviour.

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

0x80000000L does not fit into signed int.

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

0x80000000L does not fit into signed int.

>         return 0;
> }
> 
> The expected result is that 1 is printed.

No, it is undefined behaviour as overflow behaviour of signed ints is
undefined.

Bastian

-- 
Oblivion together does not frighten me, beloved.
		-- Thalassa (in Anne Mulhall's body), "Return to Tomorrow",
		   stardate 4770.3.

Attachment: signature.asc
Description: Digital signature


--- End Message ---

Reply to: