Bug using braces with Constructor and Initializing Array Members

Nelson nelson.sauve@sympatico.ca
Sat Jul 18 10:05:00 GMT 1998


Hello the egcs compiler instructed me to inform you of this error:

class Test
{
    public:
        Test();
        Test( int x );
        ~Test();
};

int main( )
{
    Test* pTestObjects;

    pTestObjects = new Test[3] = { { Test( 7 ) },
                                                      { Test( 8 ) },
                                                      { Test( 9 ) }
                                                    };
    delete [] pTestObjects;

    return( 0 );
}

The above causes an internal compiler error - while

int main( )
{
    Test* pTestObjects;

    pTestObjects = new Test[3] = { Test( 7 ),
                                                      Test( 8 ),
                                                      Test( 9 )
                                                    };
    delete [] pTestObjects;

    return( 0 );
}

Does not cause the error.

Thanks,

-Nelson





More information about the Gcc-bugs mailing list