-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp has wrong assumption #40922
Comments
This may be a bug in our optional implementation. Given: #include struct S { int main(int, char**)
return 0; I don't see why the line marked "not constexpr" shouldn't be constexpr. |
Better test: #include struct S { constexpr bool test() int main(int, char**) fails to compile thus: $ totclang2a junk.cpp |
Eric pointed out that you can't have a constexpr move-assignment operator for the non-trivial case, because it has to do a placement new (unless the optional that you are constructing from is empty) That's why my second test fails. constexpr bool test() but libc++ is not. |
Test fixed in revision 359162 - now the test is move-constructing a non-empty optional. |
Extended Description
std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp
This test assumes that move construction is not constexpr, based on this old wording quoted in the test:
// constexpr optional(const optional&& rhs);
// If is_trivially_move_constructible_v is true,
// this constructor shall be a constexpr constructor.
That was replaced by https://wg21.link/p0602r4 and now it says:
"If is_trivially_move_constructible_v is true, this constructor is trivial."
That means the constructor might still be constexpr even if it's non-trivial.
It's not clear to me whether the constructor is required to be constexpr, but I think the test is wrong to assume the move construction can't be constexpr (the test compiles using the std::optional from libstdc++, but 'lit' expects it to be ill-formed).
The text was updated successfully, but these errors were encountered: