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

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).