public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ibrbulat at yandex dot ru" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/99858] New: Wrong throw-expression behaviour with reference to pointer
Date: Wed, 31 Mar 2021 21:21:36 +0000	[thread overview]
Message-ID: <bug-99858-4@http.gcc.gnu.org/bugzilla/> (raw)

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)

             reply	other threads:[~2021-03-31 21:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31 21:21 ibrbulat at yandex dot ru [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-99858-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).