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
* [Bug c++/99858] Wrong throw-expression behaviour with reference to pointer
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 ` rguenth at gcc dot gnu.org
2021-04-01 10:50 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-01 7:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99858
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-04-01
Ever confirmed|0 |1
Keywords| |wrong-code
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
clang behaves as you expect, ICC behaves the same as GCC so it's unclear (it
might be that the ABI makes GCC/ICC behavior more natural to follow).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99858] Wrong throw-expression behaviour with reference to pointer
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
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-01 10:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99858
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
As requested by https://gcc.gnu.org/bugs/ please provide code, not just a URL.
Reduced:
extern "C" int printf(const char*, ...);
int main() try {
try {
throw (void*)1;
} catch (void*& ptr) {
printf("%p %p\n", ptr, &ptr);
ptr = nullptr;
throw;
}
} catch (void*& ptr) {
printf("%p %p\n", ptr, &ptr);
}
Not a regression. I'll take a look at the EH code.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99858] Wrong throw-expression behaviour with reference to pointer
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
3 siblings, 0 replies; 5+ messages in thread
From: foom at fuhm dot net @ 2022-06-10 21:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99858
James Y Knight <foom at fuhm dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |foom at fuhm dot net
--- Comment #3 from James Y Knight <foom at fuhm dot net> ---
This is a mess.
Clang gets it "right" only through a really awful hack, which breaks
std::rethrow_exception, and which I'm now proposing to remove.
See https://github.com/llvm/llvm-project/issues/55340#issuecomment-1152755112
I don't believe there's a way to actually get this correct in the Itanium ABI
as it stands.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99858] Wrong throw-expression behaviour with reference to pointer
2021-03-31 21:21 [Bug c++/99858] New: Wrong throw-expression behaviour with reference to pointer ibrbulat at yandex dot ru
` (2 preceding siblings ...)
2022-06-10 21:40 ` foom at fuhm dot net
@ 2023-11-19 19:14 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-19 19:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99858
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fchelnokov at gmail dot com
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 112620 has been marked as a duplicate of this bug. ***
^ 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).