------- Comment #2 from s_gccbugzilla at nedprod dot com  2008-06-08 17:19 
-------
This problem actually seems to be one of subclassing: child class rvalue
constructors invoke base class lvalue constructors!!!

I have attached an example. As is, it compiles and works. If however you throw
a Thing2 instead of Thing, you get:

[EMAIL PROTECTED]:~/Tornado/Tn/TClient/TnFOX$ g++ -o TestCPP0x -std=c++0x 
TestCPP0x.cpp
TestCPP0x.cpp: In copy constructor ‘Thing2::Thing2(const Thing2&)’:
TestCPP0x.cpp:9: error: ‘Thing::Thing(const Thing&)’ is private
TestCPP0x.cpp:12: error: within this context
TestCPP0x.cpp: In function ‘Thing2 f(bool)’:
TestCPP0x.cpp:23: note: synthesized method ‘Thing2::Thing2(const Thing2&)’
first required here

This is despite that Thing2 defines no constructors at all apart from the
default. Ok, so I tried manually disabling the lvalue constructor in Thing2
like this:

class Thing2 : public Thing {
public:
    Thing2() { }
    Thing2(Thing2&& o) : Thing(o) { }
private:
    Thing2(const Thing2&);
};

... and now I get:

[EMAIL PROTECTED]:~/Tornado/Tn/TClient/TnFOX$ g++ -o TestCPP0x -std=c++0x 
TestCPP0x.cpp
TestCPP0x.cpp: In constructor ‘Thing2::Thing2(Thing2&&)’:
TestCPP0x.cpp:9: error: ‘Thing::Thing(const Thing&)’ is private
TestCPP0x.cpp:15: error: within this context

In other words, the rvalue constructor in Thing2 is trying to invoke the lvalue
constructor in Thing!!! This is surely utterly wrong unless Thing has no rvalue
constructor. Our Thing class has the lvalue disabled and rvalue enabled, so GCC
is surely making a big mistake.

This is the shortest example of what went wrong with my exception throwing
problem.

There's an additional problem. If I don't specify any constructors at all for
Thing2 apart the default constructor, GCC /should/ generate synthesised ones
based on what's available in the parent classes. Unfortunately, GCC is ignoring
that the lvalue constructor has been disabled and tries to generate a lvalue
constructor anyway which is obviously doomed to failure.

GCC 3.4.1 just went into the Ubuntu repositories, so I'll try that next.

Niall


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36461

Reply via email to