This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc3.1 regression?
- From: Jimen Ching <jching at flex dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Wed, 8 May 2002 23:05:16 -1000 (HST)
- Subject: gcc3.1 regression?
Hi all,
The code below seems to be incorrectly compiled by gcc3.1 cvs that I
bootstraped on Debian2.2 (Linux kernel 2.2.17).
g++ -v
Reading specs from
oss/src/fsf/bin/../lib/gcc-lib/i586-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --prefix=/home/jching/oss/src/fsf
Thread model: single
gcc version 3.1 20020502 (prerelease)
Note, if you define either REMOVE_CTOR or USE_INT, the problem goes away.
The command line I used is:
g++ -O2 file.cc
If I compile without -O2 and without either of the above macros, then it
is fine. So the problem is with a combination of the char member data,
with copy constructor and level 2 optimization.
Let me know if more information is needed. I am willing to test a patch
if necessary.
Thanks.
--jc
--
Jimen Ching (WH6BRR) jching@flex.com wh6brr@uhm.ampr.org
--------------------------------
#include <iostream>
struct logic
{
enum state_value { LO, HI, DC, Z, NVL };
logic(state_value l = NVL)
: state(l) { }
#ifndef REMOVE_CTOR
logic(const logic &l)
: state(l.state) { }
#endif
#ifdef USE_INT
int state;
#else
char state;
#endif
};
const logic LO(logic::LO);
const logic HI(logic::HI);
void func(void);
int
main()
{
func();
return 0;
}
struct addtab
{
logic sum;
logic carry;
};
const struct addtab ADDTABLE[] =
{
{LO,LO},
{HI,LO},
{HI,LO},
{LO,HI},
{HI,LO},
{LO,HI},
{LO,HI},
{HI,HI}
};
void
func(void)
{
for (int tmp = 0; tmp < 8; ++tmp)
{
std::cout << (int)ADDTABLE[tmp].sum.state
<< ","
<< (int)ADDTABLE[tmp].carry.state
<< std::endl;
}
}