Internal compiler error operator- and operator if
Bas Vodde
basv@medialab.lostboys.nl
Mon Sep 18 04:19:00 GMT 2000
Hello,
On the following code I get an internal compiler error:
class CVerySimple
{
public:
CVerySimple (int inData) : mData (inData) {};
operator int () {return mData;}
CVerySimple operator - () const {return -mData;}
private:
int mData;
};
CVerySimple
Abs (CVerySimple inValue)
{
return (0 < inValue) ? inValue : -inValue;
}
void main ()
{
CVerySimple theInt = 2;
Abs (theInt);
}
I'm using gcc 2.95.2. If I rewrite the ? : operator to a normal if then it
compiles fine. Also when I remove the - in the result it compiles fine. When
I use -O1 then the internal compiler error is gone.
Compiler error:
Test.C: In function `class CVerySimple Abs<CVerySimple>(CVerySimple)':
Test.C:22: instantiated from here
Test.C:16: Internal compiler error in `instantiate_virtual_regs_1', at
function.c:3863
Bas
Bas Vodde
Software Developer
Lost Boys Medialab
www.medialab.lostboys.nl
More information about the Gcc-bugs
mailing list