[Bug c++/72580] Cannot throw non movable object

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 26 10:59:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72580

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The copy is eligible for elision, which means lookup is performed as if 'ex'
was an rvalue. That lookup finds a deleted constructor, so you get an error.

[except.throw] p5 specifically says the constructor must be non-deleted:

  When the thrown object is a class object, the constructor selected for the
  copy-initialization as well as the constructor selected for a 
  copy-initialization considering the thrown object as an lvalue shall be
  non-deleted and accessible, even if the copy/move operation is elided (12.8).

Don't delete move constructors, it doesn't make sense.


More information about the Gcc-bugs mailing list