Skip to content

Implement workaround for LLVM-46269 by ensuring that constrained destructor appears after the unconstrained one - #2630

Merged
Stephan T. Lavavej (StephanTLavavej) merged 2 commits into
microsoft:mainfrom
cpplearner:workaround-llvm-46269
Apr 4, 2022

Conversation

@cpplearner

Copy link
Copy Markdown
Contributor

This implements workaround for LLVM-46269 ("Only first destructor is considered when constraints are used").

If the constrained (and defaulted) destructor comes first, clang-cl uses it unconditionally, even if its constraints are not satisfied. This leads to an error when the defaulted destructor is implicitly deleted (due to a non-trivially-destructible member).

By moving the constrained destructor after the unconstrained one (which is always valid, but is non-trivial), this patch sidesteps the abovementioned error.

This is suboptimal, because this makes the affected types never trivially destructible when compiled with clang-cl. A perfect fix would need to use something akin to the existing _Optional_destruct_base, which I assume that we want to avoid.

@cpplearner
S. B. Tam (cpplearner) requested a review from a team as a code owner April 1, 2022 09:23
Comment thread tests/std/tests/P0896R4_views_join/test.cpp
@CaseyCarter Casey Carter (CaseyCarter) added the bug Something isn't working label Apr 1, 2022
Comment thread tests/std/tests/P0896R4_common_iterator/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_common_iterator/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_common_iterator/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_views_join/test.cpp Outdated
@CaseyCarter

Copy link
Copy Markdown
Contributor

Thanks bunches for jumping on this so quickly. I've added this PR to my list of things to ensure are in the 16.11 backport.

@CaseyCarter Casey Carter (CaseyCarter) removed their assignment Apr 1, 2022
Comment on lines +482 to +483
// To test the correct specialization of _Defaultabox, this type must not be default constructible.
non_trivially_destructible_input_iterator() = delete;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised that this doesn't trigger compiler warnings about "this class has no constructors" (usually I'd expect to see an (int, int) constructor or something similar to avoid this), but no change requested as there are apparently no test-breaking warnings.

@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for improving our Clang support! 😻 🐞 🎉

@cpplearner
S. B. Tam (cpplearner) deleted the workaround-llvm-46269 branch April 5, 2022 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ranges C++20/23 ranges

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants