public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112620] New: Changes to the referenced object in exception handler are lost after rethrow
@ 2023-11-19 16:04 fchelnokov at gmail dot com
  2023-11-19 19:14 ` [Bug c++/112620] " pinskia at gcc dot gnu.org
  2023-11-19 19:19 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: fchelnokov at gmail dot com @ 2023-11-19 16:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112620
           Summary: Changes to the referenced object in exception handler
                    are lost after rethrow
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program

#include <cstdio>

int main() {
    int i;
    try {
        try {
            throw (int*)0;
        } catch (int*& p) {
            p = &i;
            throw;
        }
    }
    catch (int*& p) {
        printf("%p", (void*)p);
    }
}

prints some not-null value in Clang and MSVC, which is correct according to
https://eel.is/c++draft/except.handle#15

> When the handler declares a reference to an object, any changes to the referenced object are changes to the exception object and will have effect should that object be rethrown.

But GCC prints (nil) here. Online demo: https://godbolt.org/z/n6s6bc17s

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

* [Bug c++/112620] Changes to the referenced object in exception handler are lost after rethrow
  2023-11-19 16:04 [Bug c++/112620] New: Changes to the referenced object in exception handler are lost after rethrow fchelnokov at gmail dot com
@ 2023-11-19 19:14 ` pinskia at gcc dot gnu.org
  2023-11-19 19:19 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ 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=112620

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 99858.

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

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

* [Bug c++/112620] Changes to the referenced object in exception handler are lost after rethrow
  2023-11-19 16:04 [Bug c++/112620] New: Changes to the referenced object in exception handler are lost after rethrow fchelnokov at gmail dot com
  2023-11-19 19:14 ` [Bug c++/112620] " pinskia at gcc dot gnu.org
@ 2023-11-19 19:19 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-19 19:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Fedor Chelnokov from comment #0) 
> prints some not-null value in Clang and MSVC, which is correct according to
> https://eel.is/c++draft/except.handle#15

Clang had a hack added to workaround the Itanium C++ ABI deficiency but that
itself broke std::rethrow_exception .
Anyways this is recorded in PR 99858 (and the linked LLVM github issue).

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-19 16:04 [Bug c++/112620] New: Changes to the referenced object in exception handler are lost after rethrow fchelnokov at gmail dot com
2023-11-19 19:14 ` [Bug c++/112620] " pinskia at gcc dot gnu.org
2023-11-19 19:19 ` 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).