Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is this the bug of gcc4.2.2

0 views
Skip to first unread message

kuangye

unread,
Aug 21, 2008, 10:29:28 PM8/21/08
to

#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;
}

0 new messages