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

[expr.const] Disjunction disqualifies construct_at of non-active member #5876

Closed
JohelEGP opened this issue Oct 1, 2022 · 3 comments
Closed

Comments

@JohelEGP
Copy link
Contributor

JohelEGP commented Oct 1, 2022

6
#
[...]
Similarly, the evaluation of a call to std​::​construct_­at or std​::​ranges​::​construct_­at ([specialized.construct]) does not disqualify E from being a core constant expression unless the first argument, of type T*, does not point to storage allocated with std​::​allocator or to an object whose lifetime began within the evaluation of E, or the evaluation of the underlying constructor call disqualifies E from being a core constant expression.

According to the wording, this code should be ill-formed, but implementations accept it: https://compiler-explorer.com/z/f8Tjx8EK5.

#include <memory>
union num {
  int i;
  constexpr num() {
    std::construct_at(&i); // the first argument does not point
    // to storage allocated with std​::​allocator<T> or
    // to an object whose lifetime began within the evaluation of E
  }
};
static_assert(num{}.i == 0);
@frederick-vs-ja
Copy link
Contributor

Perhaps this issue should be reported in the CWG repo. I think expected (probably alongwith optional and variant after P2231R1) can't work without such allowance.

@JohelEGP
Copy link
Contributor Author

JohelEGP commented Oct 4, 2022

I'd prefer a transfer.

@jwakely jwakely changed the title [expr.const] Disjunction disqualifies construct_from of non-active member [expr.const] Disjunction disqualifies construct_at of non-active member Oct 4, 2022
@JohelEGP
Copy link
Contributor Author

Opened cplusplus/CWG#155.

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