Possible parser bug in 2.96, 3.0.x and 3.1?
Julian Thomas
julian.thomas@ntlworld.com
Sat Jun 22 14:08:00 GMT 2002
I'm in the process of porting some code which has primarily been developed
using MSVC++ 6.0. I came across what looks like a possible parser bug which
seems to be present in GCC 2.96, 3.0.4 and 3.1. I've distilled the problem
down to the following test case.
-----------------------------------------------------------
#include <iostream>
class sBase
{
public:
sBase(int a=0) : ma(a) {}
int geta() { return ma; }
private:
int ma;
};
class sInherit : public sBase
{
public:
sInherit(const sBase& a, int b) : sBase(a), mb(0) {}
int getb() { return mb; }
private:
int mb;
};
// this works
static sInherit MyThing1(sBase(0), 3);
// as does this
static sInherit MyThing2 = sInherit(sBase(), 3);
// this doesn't
static sInherit MyThing3(sBase(), 3);
int main(void)
{
std::cout << "Thing a:" << MyThing1.geta() << "\n";
std::cout << "Thing b:" << MyThing1.getb() << "\n";
std::cout << "Thing a:" << MyThing2.geta() << "\n";
std::cout << "Thing b:" << MyThing2.getb() << "\n";
std::cout << "Thing a:" << MyThing3.geta() << "\n";
std::cout << "Thing b:" << MyThing3.getb() << "\n";
}
-----------------------------------------------------------
I've confirmed that it compiles correctly with both MSVC++ 6.0 and Intel C++
6.0 (and a few others too).
Any ideas, quick fixes or shiny distractions that might help me to ignore the
problem?
Julian Thomas
--
Geraldo The Singing Orangutan
Entertainments Officer for SNAR
(The Society for No Apparent Reason)
More information about the Gcc
mailing list