This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]