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

Bug#707118: marked as done (gcc-4.7: incorrect code with -O2)



Your message dated Wed, 08 May 2013 13:41:41 +0200
with message-id <518A39F5.1030704@debian.org>
and subject line Re: Bug#707118: gcc-4.7: incorrect code with -O2
has caused the Debian Bug report #707118,
regarding gcc-4.7: incorrect code with -O2
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 this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
707118: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=707118
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: gcc-4.7
Version: 4.7.2-5
Severity: grave

Dear Maintainer,

gcc produces incorrect code with -O2 for this simple example:

zaphod@eddie:~$ cat a.c

#include <string.h>
#include <stdio.h>

int foo(int);

int main(int argc, char** argv)
{
    char pstring[256];
    memset(pstring, 0, 256*sizeof(char));

    *pstring = ' ';
    strncat(pstring, "hello world", sizeof(pstring));

    *pstring = (char) (strlen(pstring) - 1);

    if (foo(strlen(pstring)) <= 0)
        return (-1);
    return 0;
}

int foo(int count)
{
    printf("%d\n", count);
    return count;
}

zaphod@eddie:~$ gcc -O0 a.c && ./a.out
12
zaphod@eddie:~$ gcc -O2 a.c && ./a.out
0

This could cause all kinds of data loss and security holes.

-- System Information:
Debian Release: 7.0
  APT prefers stable
  APT policy: (500, 'stable'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.8.7 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gcc-4.7 depends on:
ii  binutils      2.22-8
ii  cpp-4.7       4.7.2-5
ii  gcc-4.7-base  4.7.2-5
ii  libc6         2.13-38
ii  libgcc1       1:4.7.2-5
ii  libgmp10      2:5.0.5+dfsg-2
ii  libgomp1      4.7.2-5
ii  libitm1       4.7.2-5
ii  libmpc2       0.9-4
ii  libmpfr4      3.1.0-5
ii  libquadmath0  4.7.2-5
ii  zlib1g        1:1.2.7.dfsg-13

Versions of packages gcc-4.7 recommends:
ii  libc6-dev  2.13-38

Versions of packages gcc-4.7 suggests:
pn  binutils-gold        <none>
pn  gcc-4.7-doc          <none>
pn  gcc-4.7-locales      <none>
pn  gcc-4.7-multilib     <none>
pn  libcloog-ppl0        <none>
pn  libgcc1-dbg          <none>
pn  libgomp1-dbg         <none>
pn  libitm1-dbg          <none>
pn  libmudflap0-4.7-dev  <none>
pn  libmudflap0-dbg      <none>
pn  libppl-c2            <none>
pn  libppl7              <none>
pn  libquadmath0-dbg     <none>

-- no debconf information

--- End Message ---
--- Begin Message ---
severity 707118 normal
thanks

Am 07.05.2013 18:06, schrieb Philipp:
> gcc produces incorrect code with -O2 for this simple example:

invalid code. the comparison is always false and the compiler is allowed to
optimize it away.

--- End Message ---

Reply to: