public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed
@ 2021-12-09 13:36 redi at gcc dot gnu.org
  2021-12-09 13:37 ` [Bug libstdc++/103630] " redi at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-09 13:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103630
           Summary: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t)
                    is ill-formed
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: rejects-valid, wrong-code
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

I'm not 100% this is valid, but it used to work before the changes for PR
68297:

#include <exception>
int i = 0;
auto p = std::make_exception_ptr<int&>(i);

It fails now because the new implementation uses the template argument as
`_Ex*` and as `new _Ex` and those aren't valid for a reference type.

And if we fix that, there's another problem which is that it uses typeid(__ex)
which means we create an exception using the static type of the argument, but
which matches a handler of the dynamic type:

#include <exception>
#include <stdlib.h>

struct B { virtual ~B() = default; };
struct D : B { };

int main()
{
  try {
    D d;
    auto p = std::make_exception_ptr<B&>(d);
    std::rethrow_exception(p);
  } catch (const D&) {
    abort();
  } catch (const B&) {
  }
}

This throws a B but catches a D.

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

* [Bug libstdc++/103630] [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
@ 2021-12-09 13:37 ` redi at gcc dot gnu.org
  2021-12-09 13:53 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-09 13:37 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
   Last reconfirmed|                            |2021-12-09
      Known to fail|                            |10.3.0, 11.2.0, 12.0,
                   |                            |7.1.0, 9.4.0
      Known to work|                            |6.5.0
   Target Milestone|---                         |9.5
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

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

* [Bug libstdc++/103630] [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
  2021-12-09 13:37 ` [Bug libstdc++/103630] " redi at gcc dot gnu.org
@ 2021-12-09 13:53 ` redi at gcc dot gnu.org
  2021-12-09 23:29 ` cvs-commit at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-09 13:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Also, since the changes for PR 90295 <bits/exception_ptr.h> is no longer usable
in C++98:

include/bits/exception_ptr.h:182: error: declaration of
'std::__exception_ptr::exception_ptr::exception_ptr()' has a different
exception specifier
include/bits/exception_ptr.h:107: note: from previous declaration
'std::__exception_ptr::exception_ptr::exception_ptr() throw ()'
include/bits/exception_ptr.h:188: error: declaration of
'std::__exception_ptr::exception_ptr::exception_ptr(const
std::__exception_ptr::exception_ptr&)' has a different exception specifier
include/bits/exception_ptr.h:109: note: from previous declaration
'std::__exception_ptr::exception_ptr::exception_ptr(const
std::__exception_ptr::exception_ptr&) throw ()'

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

* [Bug libstdc++/103630] [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
  2021-12-09 13:37 ` [Bug libstdc++/103630] " redi at gcc dot gnu.org
  2021-12-09 13:53 ` redi at gcc dot gnu.org
@ 2021-12-09 23:29 ` cvs-commit at gcc dot gnu.org
  2021-12-09 23:33 ` [Bug libstdc++/103630] [9/10/11 " redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-09 23:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:a1ca039fc0fe934ef36c25d8284e6e116bcaffa7

commit r12-5879-ga1ca039fc0fe934ef36c25d8284e6e116bcaffa7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Dec 9 13:54:39 2021 +0000

    libstdc++: Fix std::exception_ptr regressions [PR103630]

    This restores support for std::make_exception_ptr<E&> and for using
    std::exception_ptr in C++98.

    Because the new non-throwing implementation needs to use std::decay to
    handle references the original throwing implementation is used for
    C++98.

    We also need to change the typeid expression so it doesn't yield the
    dynamic type when the function parameter is a reference to a polymorphic
    type. Otherwise the new exception object could be caught by any handler
    matching the dynamic type, even though the actual exception object is
    only a copy of the base class, sliced to the static type.

    libstdc++-v3/ChangeLog:

            PR libstdc++/103630
            * libsupc++/exception_ptr.h (exception_ptr): Fix exception
            specifications on inline definitions.
            (make_exception_ptr): Decay the template parameter. Use typeid
            of the static type.
            * testsuite/18_support/exception_ptr/103630.cc: New test.

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

* [Bug libstdc++/103630] [9/10/11 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-12-09 23:29 ` cvs-commit at gcc dot gnu.org
@ 2021-12-09 23:33 ` redi at gcc dot gnu.org
  2022-04-07 10:06 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-09 23:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11/12 Regression]     |[9/10/11 Regression]
                   |std::make_exception_ptr<T&> |std::make_exception_ptr<T&>
                   |(t) is ill-formed           |(t) is ill-formed

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk so far.

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

* [Bug libstdc++/103630] [9/10/11 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-12-09 23:33 ` [Bug libstdc++/103630] [9/10/11 " redi at gcc dot gnu.org
@ 2022-04-07 10:06 ` rguenth at gcc dot gnu.org
  2022-04-12 20:18 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-07 10:06 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug libstdc++/103630] [9/10/11 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-04-07 10:06 ` rguenth at gcc dot gnu.org
@ 2022-04-12 20:18 ` cvs-commit at gcc dot gnu.org
  2022-04-12 20:30 ` [Bug libstdc++/103630] [9/10 " redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-12 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:84e2410c8d10d7f3ca61c3063418ace8dd8f9e35

commit r11-9835-g84e2410c8d10d7f3ca61c3063418ace8dd8f9e35
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Dec 9 13:54:39 2021 +0000

    libstdc++: Fix std::exception_ptr regressions [PR103630]

    This restores support for std::make_exception_ptr<E&> and for using
    std::exception_ptr in C++98.

    Because the new non-throwing implementation needs to use std::decay to
    handle references the original throwing implementation is used for
    C++98.

    We also need to change the typeid expression so it doesn't yield the
    dynamic type when the function parameter is a reference to a polymorphic
    type. Otherwise the new exception object could be caught by any handler
    matching the dynamic type, even though the actual exception object is
    only a copy of the base class, sliced to the static type.

    libstdc++-v3/ChangeLog:

            PR libstdc++/103630
            * libsupc++/exception_ptr.h (exception_ptr): Fix exception
            specifications on inline definitions.
            (make_exception_ptr): Decay the template parameter. Use typeid
            of the static type.
            * testsuite/18_support/exception_ptr/103630.cc: New test.

    (cherry picked from commit a1ca039fc0fe934ef36c25d8284e6e116bcaffa7)

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

* [Bug libstdc++/103630] [9/10 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-04-12 20:18 ` cvs-commit at gcc dot gnu.org
@ 2022-04-12 20:30 ` redi at gcc dot gnu.org
  2022-04-26 13:12 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-12 20:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11 Regression]        |[9/10 Regression]
                   |std::make_exception_ptr<T&> |std::make_exception_ptr<T&>
                   |(t) is ill-formed           |(t) is ill-formed

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 11.3 too.

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

* [Bug libstdc++/103630] [9/10 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-04-12 20:30 ` [Bug libstdc++/103630] [9/10 " redi at gcc dot gnu.org
@ 2022-04-26 13:12 ` cvs-commit at gcc dot gnu.org
  2022-04-26 13:14 ` [Bug libstdc++/103630] [9 " redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-26 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:02b601ad7ea06460e7bc42d7251e895d9031bc6e

commit r10-10570-g02b601ad7ea06460e7bc42d7251e895d9031bc6e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Dec 9 13:54:39 2021 +0000

    libstdc++: Fix std::exception_ptr regressions [PR103630]

    This restores support for std::make_exception_ptr<E&> and for using
    std::exception_ptr in C++98.

    Because the new non-throwing implementation needs to use std::decay to
    handle references the original throwing implementation is used for
    C++98.

    We also need to change the typeid expression so it doesn't yield the
    dynamic type when the function parameter is a reference to a polymorphic
    type. Otherwise the new exception object could be caught by any handler
    matching the dynamic type, even though the actual exception object is
    only a copy of the base class, sliced to the static type.

    libstdc++-v3/ChangeLog:

            PR libstdc++/103630
            * libsupc++/exception_ptr.h (make_exception_ptr): Decay the
            template parameter. Use typeid of the static type.
            * testsuite/18_support/exception_ptr/103630.cc: New test.

    (cherry picked from commit a1ca039fc0fe934ef36c25d8284e6e116bcaffa7)

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

* [Bug libstdc++/103630] [9 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-04-26 13:12 ` cvs-commit at gcc dot gnu.org
@ 2022-04-26 13:14 ` redi at gcc dot gnu.org
  2022-05-09 16:40 ` cvs-commit at gcc dot gnu.org
  2022-05-09 16:50 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-26 13:14 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10 Regression]           |[9 Regression]
                   |std::make_exception_ptr<T&> |std::make_exception_ptr<T&>
                   |(t) is ill-formed           |(t) is ill-formed

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
And 10.4 now.

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

* [Bug libstdc++/103630] [9 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2022-04-26 13:14 ` [Bug libstdc++/103630] [9 " redi at gcc dot gnu.org
@ 2022-05-09 16:40 ` cvs-commit at gcc dot gnu.org
  2022-05-09 16:50 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-09 16:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:93a621991615e943704ed1a957d934736bf8a3d3

commit r9-10063-g93a621991615e943704ed1a957d934736bf8a3d3
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Dec 9 13:54:39 2021 +0000

    libstdc++: Fix std::exception_ptr regressions [PR103630]

    This restores support for std::make_exception_ptr<E&> and for using
    std::exception_ptr in C++98.

    Because the new non-throwing implementation needs to use std::decay to
    handle references the original throwing implementation is used for
    C++98.

    We also need to change the typeid expression so it doesn't yield the
    dynamic type when the function parameter is a reference to a polymorphic
    type. Otherwise the new exception object could be caught by any handler
    matching the dynamic type, even though the actual exception object is
    only a copy of the base class, sliced to the static type.

    libstdc++-v3/ChangeLog:

            PR libstdc++/103630
            * libsupc++/exception_ptr.h (make_exception_ptr): Decay the
            template parameter. Use typeid of the static type.
            * testsuite/18_support/exception_ptr/103630.cc: New test.

    (cherry picked from commit a1ca039fc0fe934ef36c25d8284e6e116bcaffa7)

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

* [Bug libstdc++/103630] [9 Regression] std::make_exception_ptr<T&>(t) is ill-formed
  2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2022-05-09 16:40 ` cvs-commit at gcc dot gnu.org
@ 2022-05-09 16:50 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-09 16:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
And 9.5 too.

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

end of thread, other threads:[~2022-05-09 16:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 13:36 [Bug libstdc++/103630] New: [9/10/11/12 Regression] std::make_exception_ptr<T&>(t) is ill-formed redi at gcc dot gnu.org
2021-12-09 13:37 ` [Bug libstdc++/103630] " redi at gcc dot gnu.org
2021-12-09 13:53 ` redi at gcc dot gnu.org
2021-12-09 23:29 ` cvs-commit at gcc dot gnu.org
2021-12-09 23:33 ` [Bug libstdc++/103630] [9/10/11 " redi at gcc dot gnu.org
2022-04-07 10:06 ` rguenth at gcc dot gnu.org
2022-04-12 20:18 ` cvs-commit at gcc dot gnu.org
2022-04-12 20:30 ` [Bug libstdc++/103630] [9/10 " redi at gcc dot gnu.org
2022-04-26 13:12 ` cvs-commit at gcc dot gnu.org
2022-04-26 13:14 ` [Bug libstdc++/103630] [9 " redi at gcc dot gnu.org
2022-05-09 16:40 ` cvs-commit at gcc dot gnu.org
2022-05-09 16:50 ` redi 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).