Package: g++-4.6
Version: 4.6.0-8
Severity: important
The attached test program is supposed to print -42, and does so when
compiled with g++-4.4 or g++-4.5. However, it outputs random junk when
compiled with g++-4.6:
$ g++ -Wall -O2 test.cxx
$ ./a.out
31
$ ./a.out
207
$ ./a.out
79
We've discussed this code on #debian-devel and nobody could find any bug
in it, so the only explanation is that it's g++ that miscompiles it.
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'experimental')
Architecture: i386 (x86_64)
Kernel: Linux 2.6.38-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages g++-4.6 depends on:
ii gcc-4.6 4.6.0-8 The GNU C compiler
ii gcc-4.6-base 4.6.0-8 The GNU Compiler Collection (base
ii libc6 2.13-4 Embedded GNU C Library: Shared lib
ii libcloog-ppl0 0.15.9-3 the Chunky Loop Generator (runtime
ii libgmp10 2:5.0.1+dfsg-7 Multiprecision arithmetic library
ii libgmpxx4ldbl 2:5.0.1+dfsg-7 Multiprecision arithmetic library
ii libmpc2 0.9-3 multiple precision complex floatin
ii libmpfr4 3.0.1-3 multiple precision floating-point
ii libppl-c4 0.11.2-3 Parma Polyhedra Library (C interfa
ii libppl9 0.11.2-3 Parma Polyhedra Library (runtime l
ii libstdc++6-4.6-dev 4.6.0-8 The GNU Standard C++ Library v3 (d
ii zlib1g 1:1.2.5.dfsg-1 compression library - runtime
Versions of packages g++-4.6 suggests:
pn g++-4.6-multilib <none> (no description available)
pn gcc-4.6-doc <none> (no description available)
ii libstdc++6-4.6-dbg 4.6.0-8 The GNU Standard C++ Library v3 (d
--
Jakub Wilk
#include <iostream>
int f()
{
unsigned char data[3] = { 42, 42, 42 };
unsigned char *begin = data;
unsigned char *end = data + 3;
std::reverse_iterator<unsigned char *> reversed(end);
for (; begin < end; begin++, reversed++)
if (*reversed != 42)
return *reversed;
return -42;
}
int main(int argc, char ** argv)
{
std::cout << f() << "\n";
}