[Bug c++/36461] [c++0x] Exception throws don't use rvalue reference constructors

2008-09-24 Thread dgregor at gcc dot gnu dot org


--- Comment #4 from dgregor at gcc dot gnu dot org  2008-09-24 20:20 ---
GCC is doing the right thing here. In this constructor:

  Thing2(Thing2 o) : Thing(o) { }

the parameter o is treated as an lvalue, because it has a name. Using
std::move(o) to treat it as an rvalue.

Similarly, there are no automatically generated move constructors or
move-assignment operators, so if you leave Thing2() empty, you'll just get the
copy constructor and therefore do a copy.


-- 

dgregor at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID


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



[Bug c++/36461] [c++0x] Exception throws don't use rvalue reference constructors

2008-06-08 Thread s_gccbugzilla at nedprod dot com


--- Comment #1 from s_gccbugzilla at nedprod dot com  2008-06-08 17:07 
---
Created an attachment (id=15732)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15732action=view)
Test Case


-- 


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



[Bug c++/36461] [c++0x] Exception throws don't use rvalue reference constructors

2008-06-08 Thread s_gccbugzilla at nedprod dot com


--- 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



[Bug c++/36461] [c++0x] Exception throws don't use rvalue reference constructors

2008-06-08 Thread s_gccbugzilla at nedprod dot com


--- Comment #3 from s_gccbugzilla at nedprod dot com  2008-06-08 17:19 
---
Created an attachment (id=15733)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15733action=view)
Failing


-- 


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