[Bug c++/57533] New: When throwing local variable, it's being move-constructed even if not going out of scope.
asaelr at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 5 12:08:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57533
Bug ID: 57533
Summary: When throwing local variable, it's being
move-constructed even if not going out of scope.
Product: gcc
Version: 4.7.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: asaelr at gmail dot com
Created attachment 30260
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30260&action=edit
example file. (compile with -std=c++0x, and look at the string s)
When throwing variable, a copy of it is actually being throwed.
In c++0x, The compiler may optimize it to move (instead of copy), if this
variable is local, and is going out of scope (for example, if it's not in a try
block, the function will end).
However, gcc 4.7.3 does this optimization even if the variable is not going out
of scope.
As a result, the variable becomes invalid.
More information about the Gcc-bugs
mailing list