public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57533] New: When throwing local variable, it's being move-constructed even if not going out of scope.
@ 2013-06-05 12:08 asaelr at gmail dot com
  2013-06-05 12:13 ` [Bug c++/57533] " redi at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: asaelr at gmail dot com @ 2013-06-05 12:08 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-12-17 11:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-05 12:08 [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
2013-06-05 12:13 ` [Bug c++/57533] " redi at gcc dot gnu.org
2013-06-05 12:17 ` paolo.carlini at oracle dot com
2013-10-05 12:25 ` dmitriy-hshg at mail dot ru
2014-08-23 23:32 ` ville.voutilainen at gmail dot com
2015-04-12 21:08 ` redi at gcc dot gnu.org
2021-02-04 10:39 ` redi at gcc dot gnu.org
2021-02-04 10:55 ` redi at gcc dot gnu.org
2021-02-04 10:59 ` redi at gcc dot gnu.org
2021-12-17 11:25 ` pinskia at gcc dot gnu.org

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).