public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99858] New: Wrong throw-expression behaviour with reference to pointer
@ 2021-03-31 21:21 ibrbulat at yandex dot ru
  2021-04-01  7:38 ` [Bug c++/99858] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ibrbulat at yandex dot ru @ 2021-03-31 21:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99858

            Bug ID: 99858
           Summary: Wrong throw-expression behaviour with reference to
                    pointer
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ibrbulat at yandex dot ru
  Target Milestone: ---

If you catch an exception of pointer type by reference to pointer, change the
value of the pointer inside this catch block and then rethrow it via *throw*
with no operand, compiler will create a copy of initial exception(!) and no
changes will be seen in the next handler.
Minimal example is here https://godbolt.org/z/T11939EYM

This behavior is contrary to the C ++ language standard (e.g. C++17):
[expr.throw]: "... 3. A throw-expression with no operand rethrows the currently
handled exception (18.3). The exception is reactivated with the existing
exception object; no new exception object is created. ..."
[except.throw]: "... If a handler exits by rethrowing, control is passed to
another handler for the same exception object.  ..."

However it works well with other (non-pointer) types - no additional copy is
created, all handlers work with the same object and see each other changes
(example: https://godbolt.org/z/Ea6r1z7rE)

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

end of thread, other threads:[~2023-11-19 19:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 21:21 [Bug c++/99858] New: Wrong throw-expression behaviour with reference to pointer ibrbulat at yandex dot ru
2021-04-01  7:38 ` [Bug c++/99858] " rguenth at gcc dot gnu.org
2021-04-01 10:50 ` redi at gcc dot gnu.org
2022-06-10 21:40 ` foom at fuhm dot net
2023-11-19 19:14 ` 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).