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

Bug#372913: gcc-4.1: datatype limits / signedness differs with optimization levels



Package: gcc-4.1
Version: 4.1.1-2
Severity: critical
Justification: breaks unrelated software

Use this little example to see what's happening:

#include <stdio.h>

int main(void) {
        char c = '\0';

        do {
                printf("%d\n", c);

                c++;
        } while (c != '\0');

        return 0;
}

- using -O0 as optimization level with gcc-4.1 works as expected: the values change from 0 over 127, -128 (because of the signedness) back to 0
- using -O1 with gcc-4.1 makes the values go from 0 to 255
- using -O2 (or higher) results in an infinite loop

This also occurs in gcc-snapshot and does not in gcc < 4.1.

Regards,
Erik

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-2-k7
Locale: LANG=de_DE@euro, LC_CTYPE=de_DE@euro (charmap=ISO-8859-15) (ignored: LC_ALL set to de_DE@euro)

Versions of packages gcc-4.1 depends on:
ii  binutils             2.16.1cvs20060413-1 The GNU assembler, linker and bina
ii  cpp-4.1              4.1.1-2             The GNU C preprocessor
ii  gcc-4.1-base         4.1.1-2             The GNU Compiler Collection (base 
ii  libc6                2.3.6-15            GNU C Library: Shared libraries
ii  libgcc1              1:4.1.1-2           GCC support library

Versions of packages gcc-4.1 recommends:
ii  libc6-dev                     2.3.6-15   GNU C Library: Development Librari
ii  libmudflap0-dev               4.1.1-2    GCC mudflap support libraries (dev
ii  libssp0-dev                   4.1.1-2    GCC stack smashing protection libr

-- no debconf information



Reply to: