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

Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arthur.j.odwyer at gmail dot 
com

--- Comment #1 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
(Sorry, not sure where's the best place to put this comment. Maybe nowhere. ;))
You probably know this already, but just in case anyone's not on the same page
yet:

https://eel.is/c++draft/except.throw#5
> When the thrown object is a class object, the constructor selected for the 
> copy-initialization *as well as the constructor selected for a 
> copy-initialization considering the thrown object as an lvalue* shall be 
> non-deleted and accessible, even if the copy/move operation is elided.

That paragraph is lurking in the background every time we talk about GCC's
handling of move-only exception objects. However, my impression is that the
paragraph is ignorable from the vendor's point of view:

- Even on paper, this "shall" is talking only about the runtime behavior "when
an exception _is_ thrown," so it doesn't change anything about the
well-formedness of _unevaluated_ throw-expressions.

- GCC+Clang _probably could_ conformingly decide that it should be ill-formed
to `throw x` when `x` is move-only; but that would break a lot of users, so
pragmatically they can't do that. GCC+Clang need a consistent theory of what it
means to throw a move-only type, and the theory can't possibly be "it's
ill-formed" (because that would break users), so the theory must agree with
Marek's test case: `throw t` ought to be well-formed in C++20-and-later (by
wording introduced to C++20 in P1155 a.k.a. P1825).

IOW, this bug and test case are *not* invalidated by [except.throw]/5. That's
all. :)

Reply via email to