public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58629] New: Do not implicit move instance for throw operator
@ 2013-10-05 11:59 dmitriy-hshg at mail dot ru
  2013-10-05 12:06 ` [Bug c++/58629] " paolo.carlini at oracle dot com
  2013-10-05 12:25 ` dmitriy-hshg at mail dot ru
  0 siblings, 2 replies; 3+ messages in thread
From: dmitriy-hshg at mail dot ru @ 2013-10-05 11:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58629

            Bug ID: 58629
           Summary: Do not implicit move instance for throw operator
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmitriy-hshg at mail dot ru

Created attachment 30959
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30959&action=edit
Example

It is good idea to use move semantics for throw operator: 

    std::runtime_error error("message");
    ...
    throw error; // execution of this block ends => we can implicit move
'error'.

but it may be used only for instances (variables) defined in try {} block. For
other instances a copy semantics must be applied:

    std::runtime_error error("message");
    ...
    try {
        ...
        throw error; // we can return to outside block and get access to
'error' again => we must copy 'error' 
    } catch (std::runtime_error &e) {
        std::cout << error.what(); // It must be OK!
    }

I have attached an example of code. In GCC instance is always implicity moved.



Expected result:

'error' must be valid in catch(){} block

Actual result:

'error' is invalid in catch(){} block because it is moved in throw error;


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

* [Bug c++/58629] Do not implicit move instance for throw operator
  2013-10-05 11:59 [Bug c++/58629] New: Do not implicit move instance for throw operator dmitriy-hshg at mail dot ru
@ 2013-10-05 12:06 ` paolo.carlini at oracle dot com
  2013-10-05 12:25 ` dmitriy-hshg at mail dot ru
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-05 12:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58629

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Did you search bugzilla before filing the bug? I'm asking because I'm pretty
sure we already have something closely related.


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

* [Bug c++/58629] Do not implicit move instance for throw operator
  2013-10-05 11:59 [Bug c++/58629] New: Do not implicit move instance for throw operator dmitriy-hshg at mail dot ru
  2013-10-05 12:06 ` [Bug c++/58629] " paolo.carlini at oracle dot com
@ 2013-10-05 12:25 ` dmitriy-hshg at mail dot ru
  1 sibling, 0 replies; 3+ messages in thread
From: dmitriy-hshg at mail dot ru @ 2013-10-05 12:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58629

Dmitry <dmitriy-hshg at mail dot ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Dmitry <dmitriy-hshg at mail dot ru> ---
Thank you!

*** This bug has been marked as a duplicate of bug 57533 ***


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

end of thread, other threads:[~2013-10-05 12:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-05 11:59 [Bug c++/58629] New: Do not implicit move instance for throw operator dmitriy-hshg at mail dot ru
2013-10-05 12:06 ` [Bug c++/58629] " paolo.carlini at oracle dot com
2013-10-05 12:25 ` dmitriy-hshg at mail dot ru

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