This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/24804] New: Produces wrong code
- From: "abottema at mathworks dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Nov 2005 17:15:04 -0000
- Subject: [Bug c++/24804] New: Produces wrong code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Compile the following program (minimized from a larger context) with
'g++ -O3 -fno-strict-aliasing foo.cpp' (on a Linux i386 32-bit machine
with gcc 3.4.4)
foo.cpp:
===================================================================
class DummyType
{
public:
inline DummyType() { }
inline ~DummyType() { }
};
class Foo
{
public:
Foo() : X0(0), X4(0) { }
int X0, X1, X2, X3, X4;
};
int main()
{
{
Foo f;
DummyType();
}
Foo f2;
while (1) {
if (f2.X4 != 0) {
f2.X4 = 0;
} else {
break;
}
}
return 0;
}
=================================================================
It will hang if you execute it.
It does not hang if you do _one_ of the following things:
- Compile with -O1 (instead of -O3)
- Remove compiler flag -fno-strict-aliasing
- Replace all occurrences of 'f2.X4' with 'f2.X3'
- Remove the statement 'DummyType();'
- Remove the statement 'Foo f;'
--
Summary: Produces wrong code
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: abottema at mathworks dot com
GCC build triplet: ix86-linux
GCC host triplet: ix86-linux
GCC target triplet: ix86-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24804