This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53364] New: [4.7/4.8 Regression] Wrong code generation
- From: "foom at fuhm dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 15 May 2012 19:21:48 +0000
- Subject: [Bug c++/53364] New: [4.7/4.8 Regression] Wrong code generation
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53364
Bug #: 53364
Summary: [4.7/4.8 Regression] Wrong code generation
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: foom@fuhm.net
On the following code, minimized from a much larger program:
test.cpp
=====================
#include <algorithm>
struct A
{
int m_x;
explicit A(int x) : m_x(x) {}
operator int() const { return m_x; }
};
struct B : public A
{
public:
explicit B(int x)
: A(x) {}
};
int data = 1;
int main() {
B b = B(10);
b = std::min(b, B(data));
return int(b);
}
=================
Running: g++ -O2 -c test.cpp
With gcc version: g++ (Debian 4.7.0-8) 4.7.0
(which says it's built from r187339 on the gcc 4.7 branch).
On architecture: x86-64
The program ought to return 1, but instead, it returns randomness. Running
valgrind confirms that this program is using uninitialized values.
Testing with the debian gcc-snapshot package (trunk rev 187013) shows the same
bug.
Testing with the debian gcc 4.6.3 package does not show the bug.
Using -O1 does not show the bug.
Using -O1 -fstrict-aliasing shows the bug.