problem with temporary objects
Dallas Morlock
dallas@daktel.com
Fri Feb 6 11:20:00 GMT 1998
egcs gives an error for this code. I think this is a bug.
-------
$ g++ -v
Reading specs from
/mnt/space/egcs-980205/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.07/specs
gcc version egcs-2.91.07 980205 (gcc-2.8.0 release)
$ g++ -c TempTest.cc
TempTest.cc: In function `void f()':
TempTest.cc:17: `class TestClass TestClass::EnumValue' is not a static
member of `class TestClass'
TempTest.cc:17: parse error before `.'
-------
class TestClass
{
public:
enum EnumType { EnumValue };
TestClass(EnumType);
TestClass();
void f();
};
void
g()
{
// explicit temp with enum argument works
TestClass temp(TestClass::EnumValue); temp.f(); // explicit temp works
// implicit temp with enum argument doesn't work
TestClass(TestClass::EnumValue).f(); // LINE 17
// implicit temp without enum argument works
TestClass().f();
}
--
Dallas Morlock
dallas@daktel.com
More information about the Gcc-bugs
mailing list