This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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
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

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.


Jimen Ching (WH6BRR)

#include <iostream>

struct logic
	enum state_value { LO, HI, DC, Z, NVL };

	logic(state_value l = NVL)
		: state(l) { }
	logic(const logic &l)
		: state(l.state) { }

#ifdef USE_INT
	int state;
	char state;

const logic  LO(logic::LO);
const logic  HI(logic::HI);

void func(void);

	return 0;

struct addtab
	logic sum;
	logic carry;
const struct addtab ADDTABLE[] =

	for (int tmp = 0; tmp < 8; ++tmp)
		std::cout << (int)ADDTABLE[tmp].sum.state
				  << ","
				  << (int)ADDTABLE[tmp].carry.state
				  << std::endl;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]