[Bug c++/62172] Operand to a throw expression is moved when it should be copied

ville.voutilainen at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Aug 18 16:02:00 GMT 2014


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

Ville Voutilainen <ville.voutilainen at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-08-18
                 CC|                            |ville.voutilainen at gmail dot com
     Ever confirmed|0                           |1

--- Comment #1 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Reduced:

#include <cassert>

int move_count = 0;
struct X {
  X() = default;
  X(const X&) = default;
  X(X&&) {++move_count;}
};

int main()
{
  X x;
  try {throw x;}
  catch (X&) {}
  assert(move_count==0);
}

Asserts on gcc, doesn't assert on clang.



More information about the Gcc-bugs mailing list