-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
<variant>: P0608R3 Improving variant's converting constructor/assignment #1629
Conversation
This is a squash of multiple commits for readability Changes according to P1957R2 Adjust variant type selection templates, add unit tests
- Also propagate the type as R-value correctly Co-Authored-By: Igor Zhukov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are disabled libc++ tests.
https://github.com/microsoft/STL/blob/main/tests/libcxx/expected_results.txt#L302-L306
and
https://github.com/microsoft/STL/blob/main/tests/libcxx/skipped_tests.txt#L302-L306
Just remove the lines and add the change to your pull request.
By the way, gcc and clang failed with 3 asserts:
|
Co-Authored-By: Igor Zhukov <[email protected]>
These are my thoughts regarding these differences:
static_assert(is_constructible_v<variant<bool>, convertible_bool>); should be valid because Also, looking at
static_assert(!is_constructible_v<variant<double_double>, int>); I would like to know your input, and maintainers' input as well 🐱. |
Yes, I think you're right. By the way. I found that And gcc(trunc) fix the issue: https://gcc.godbolt.org/z/brMhqx |
So then you will have time could you add Similar to the lines: https://github.com/microsoft/STL/blob/main/tests/std/tests/P0466R5_layout_compatibility_and_pointer_interconvertibility_traits/test.cpp#L18 Next we can file the failed asserts here: https://bugs.llvm.org/ and add |
I will make sure the unit tests are passing with Also, I would like to re-visit my second point I mentioned earlier in the discussion about: static_assert(!is_constructible_v<variant<double_double>, int>); I found out msvc and gcc results are different, I took out the code I am using to build |
libc++ tests failed, yes. I will try to figure out why...
|
I wrote the failed libc++ assertions: https://gcc.godbolt.org/z/nY7a4P |
|
With trunk versions of compilers the assertions fail too: https://gcc.godbolt.org/z/599fG9 (with clang + libstdc++ too) So you're correct, just disable the libc++ tests... |
This commit re-disables libc++ tests and guards tests which exhibit a behavior where narrowing conversion in user-defined type constructor is allowed by clang-cl and disallowed by cl. I assume cl is correct with this commit. Co-Authored-By: Igor Zhukov <[email protected]>
Notes about the one remaining failure:
|
Great. I can't add the changes here but I created pull request: https://github.com/MichaelRizkalla/STL/pull/2 |
Co-Authored-By: S. B. Tam <[email protected]>
* Guard failing tests on EDG Co-Authored-By: Michael S. Rizkalla <[email protected]>
tests/std/tests/P0608R3_sane_variant_converting_constructor/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/P0608R3_sane_variant_converting_constructor/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/P0608R3_sane_variant_converting_constructor/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/P0608R3_sane_variant_converting_constructor/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/P0608R3_sane_variant_converting_constructor/test.cpp
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I rerun the EDG tests after commit "Make sure base class members are visible" (2d4c87b) without
So |
tests/std/tests/P0608R3_improved_variant_converting_constructor/test.cpp
Show resolved
Hide resolved
tests/std/tests/P0608R3_improved_variant_converting_constructor/test.cpp
Outdated
Show resolved
Hide resolved
I think we may need to make this conditional on C++20. That's the default for all new features - unconditional implementation is special, and reserved for invasive changes to existing machinery that are non-disruptive. (The At first, I thought this satisfied those criteria. However, after seeing a source break in the compiler's own code where it was narrowing I'll investigate making this change. |
Casey suggested _TargetType and _InitializerType to avoid confusion. constexpr is unnecessary for _Construct_array. typename/template keywords aren't necessary as _Variant_type_test isn't templated.
I pushed the following changes:
|
Mirrored to internal MSVC-PR-304537 with changes to fix the compiler's own usage of Please note: Further changes are still possible (e.g. if you notice something, or if final review leads to more feedback that should be addressed before merging), but they must be replicated to the mirror PR in order to avoid codebase divergence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a metaprogramming simplification; looks good otherwise.
Co-authored-by: Casey Carter <[email protected]>
Thanks for implementing C++20's variant of these constraints, helping users avoid unexpected results! 😹 🚀 🎉 |
This PR implements P0608R3. if successful will close #27.
Locally, one test fails with "clang-cl":That's an inconsistency between MSVC and clang-cl, and I think MSVC is correct. (assuming I am doing everything in a correct way)