This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

Internal compiler error operator- and operator if


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



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