Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CWG2886 [class.temporary] noexcept operator with trivial but potentially-throwing special member functions #531

Open
frederick-vs-ja opened this issue Apr 27, 2024 · 1 comment

Comments

@frederick-vs-ja
Copy link

frederick-vs-ja commented Apr 27, 2024

Full name of submitter (unless configured in github; will be published with the issue): Jiang An

Reference (section label): [class.temporary]

Link to reflector thread (if any):

Issue description:

[class.temporary] p4 seemingly allows, but does not guarantee, that a trivial special member function is not called in the mentioned cases. As P1286R2 allowed trivial, eligible/non-deleted, but potentially-throwing (noexcept(false)) special member functions, the difference on whether such a special member function is called can be observed by a noexcept-expression.

There is implementation divergence on this (Godbolt link). It's unclear whether the implementation divergence is intended.

struct TrivialButPotentiallyThrowingDestructor {
    TrivialButPotentiallyThrowingDestructor() = default;
    ~TrivialButPotentiallyThrowingDestructor() noexcept(false) = default;
};

static_assert(noexcept(TrivialButPotentiallyThrowingDestructor{}), "???"); // EDG thinks the dtor is called, while others don't.

Also, it is unclear in [class.temporary] p3 whether the constructor or destructor call in the creation of a temporary object holding the function parameter is considered observable via a noexcept-expression. It seems intended that the implementation should only perform bitwise copy and the exception specification shouldn't be considered.

Suggested resolution:

@frederick-vs-ja frederick-vs-ja changed the title [class.temporary] noexcept with trivial but potentially-throwing special member functions [class.temporary] noexcept operator with trivial but potentially-throwing special member functions Apr 27, 2024
@jensmaurer jensmaurer changed the title [class.temporary] noexcept operator with trivial but potentially-throwing special member functions CWG2886 [class.temporary] noexcept operator with trivial but potentially-throwing special member functions Apr 29, 2024
@jensmaurer
Copy link
Member

CWG2886

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants