This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16791] New: comparison test for enum values fails when optimized
- From: "thiessen at ncbi dot nlm dot nih dot gov" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Jul 2004 23:26:20 -0000
- Subject: [Bug c++/16791] New: comparison test for enum values fails when optimized
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This looks a lot like bug #15069, which was marked fixed for 3.4.1 (as far as I
can tell - I'm new to GCC Bugzilla). However, I'm using GCC 3.4.1 on linux, and
I'm seeing a problem with the code:
#include <iostream>
using namespace std;
// atom type
enum eAtomClassification {
eSideChainAtom,
eAlphaBackboneAtom,
ePartialBackboneAtom,
eCompleteBackboneAtom,
eUnknownAtom
};
int main(int argc, char **argv)
{
eAtomClassification classification = eUnknownAtom;
if ((classification == eAlphaBackboneAtom) ||
(classification == ePartialBackboneAtom) ||
(classification == eCompleteBackboneAtom))
{
cout << "error:\n";
cout << "class " << classification << "\n" << flush;
cout << eAlphaBackboneAtom << " "
<< ePartialBackboneAtom
<< " " << eCompleteBackboneAtom << "\n" << flush;
return 1;
}
cout << "okay\n";
return 0;
}
When compiled with optimization, it doesn't execute properly:
(trans)(~/tmp) g++ -O1 -o gcc-bug-2 gcc-bug-2.cpp
(trans)(~/tmp) gcc-bug-2
error:
class 4
1 2 3
(trans)(~/tmp) g++ -O2 -o gcc-bug-2 gcc-bug-2.cpp
(trans)(~/tmp) gcc-bug-2
error:
class 4
1 2 3
(trans)(~/tmp) g++ -O0 -o gcc-bug-2 gcc-bug-2.cpp
(trans)(~/tmp) gcc-bug-2
okay
Is this the same bug #15069, or is it something different? In any case, it's not
working in 3.4.1... My version:
(trans)(~/tmp) g++ -v
Reading specs from /usr/lib/gcc-3.4.1/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: ./configure --prefix=/usr/local/gcc-3.4.1
--libdir=/usr/lib/gcc-3.4.1 --with-include=/usr/local/gcc-3.4.1/include
--enable-threads --enable-shared --enable-languages=c,c++,f77,java
--with-gxx-include-dir=/usr/local/gcc-3.4.1/include/g++-v3
Thread model: posix
gcc version 3.4.1
--
Summary: comparison test for enum values fails when optimized
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: critical
Priority: P1
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: thiessen at ncbi dot nlm dot nih dot gov
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16791