public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/62172] New: Operand to a throw expression is moved when it should be copied @ 2014-08-18 15:34 tsimpson at ubuntu dot com 2014-08-18 16:02 ` [Bug c++/62172] " ville.voutilainen at gmail dot com ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: tsimpson at ubuntu dot com @ 2014-08-18 15:34 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62172 Bug ID: 62172 Summary: Operand to a throw expression is moved when it should be copied Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tsimpson at ubuntu dot com Created attachment 33352 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33352&action=edit test case With a throw expression whos operand is an lvalue, which is declared outside the try block, will move from the expression instead of copy. The relavent part of the standard is 15.1 [except.throw]. The C++11 standard *could* be interpreded to allow the move when reading the last sentence of 15.1/3 "...Except for these restrictions and the restrictions on type matching mentioned in 15.3, the operand of throw is treated exactly as a function argument in a call (5.2.2) or the operand of a return statement." Specifically, if the operand of the throw expression was treated exactly the same as an operand to a return statement then it would become an xvalue and the move would be allowed. The wording of that clause changed in C++14, so this is no longer the case. And I don't think it was the intent to allow that in C++11 either. Example output with g++ http://rextester.com/USFXJ5678 Exmaple output with clang++ http://rextester.com/EARQ18237 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/62172] Operand to a throw expression is moved when it should be copied 2014-08-18 15:34 [Bug c++/62172] New: Operand to a throw expression is moved when it should be copied tsimpson at ubuntu dot com @ 2014-08-18 16:02 ` ville.voutilainen at gmail dot com 2014-08-23 23:28 ` redi at gcc dot gnu.org 2014-08-23 23:32 ` ville.voutilainen at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: ville.voutilainen at gmail dot com @ 2014-08-18 16:02 UTC (permalink / raw) To: gcc-bugs 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. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/62172] Operand to a throw expression is moved when it should be copied 2014-08-18 15:34 [Bug c++/62172] New: Operand to a throw expression is moved when it should be copied tsimpson at ubuntu dot com 2014-08-18 16:02 ` [Bug c++/62172] " ville.voutilainen at gmail dot com @ 2014-08-23 23:28 ` redi at gcc dot gnu.org 2014-08-23 23:32 ` ville.voutilainen at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: redi at gcc dot gnu.org @ 2014-08-23 23:28 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62172 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- I think this is a DUP of an existing report ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/62172] Operand to a throw expression is moved when it should be copied 2014-08-18 15:34 [Bug c++/62172] New: Operand to a throw expression is moved when it should be copied tsimpson at ubuntu dot com 2014-08-18 16:02 ` [Bug c++/62172] " ville.voutilainen at gmail dot com 2014-08-23 23:28 ` redi at gcc dot gnu.org @ 2014-08-23 23:32 ` ville.voutilainen at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: ville.voutilainen at gmail dot com @ 2014-08-23 23:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62172 Ville Voutilainen <ville.voutilainen at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |DUPLICATE --- Comment #3 from Ville Voutilainen <ville.voutilainen at gmail dot com> --- Dup, the testcases are almost identical. *** This bug has been marked as a duplicate of bug 57533 *** ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-23 23:32 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-08-18 15:34 [Bug c++/62172] New: Operand to a throw expression is moved when it should be copied tsimpson at ubuntu dot com 2014-08-18 16:02 ` [Bug c++/62172] " ville.voutilainen at gmail dot com 2014-08-23 23:28 ` redi at gcc dot gnu.org 2014-08-23 23:32 ` ville.voutilainen at gmail dot com
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).