bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is this the bug of gcc4.2.2


From: kuangye
Subject: Is this the bug of gcc4.2.2
Date: Thu, 21 Aug 2008 19:29:28 -0700 (PDT)
User-agent: G2/1.0

#include <iostream>
using namespace std;
class TSB
{
//-------------->
        friend TSB fnbase();
//-------------->
protected:
        TSB()
        {
                cout<<"TSB()"<<endl;
        }
        TSB(const TSB&other)
        {
                cout<<"TSB(const TSB&other)"<<endl;
        }
public:
        ~TSB()
        {
                cout<<"~TSB()"<<endl;
        }
};

class TS:public TSB
{
public:
        TS()
        {
                cout<<"TS()"<<endl;
        }
//-------------->
        TS(const TSB&other)
        {
                cout<<"TS(const TSB&other)"<<endl;
        }

        TS(const TS&other)
        {
                cout<<"TS(const TS&other)"<<endl;
        }
        ~TS()
        {
                cout<<"~TS()"<<endl;
        }
};



TSB fnbase()
{
        return TSB();
}

//-------------->
TS fn()
{
        //in gcc 4.2.2, the following statement will cause compiling error.
        //but it works in gcc 3.4
        return TS(fnbase());

}



int main()
{
        TS ts = fn();
        return 0;
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]