This is an archive of the discontinued LLVM Phabricator instance.

[libc++][test] Avoid MSVC constexpr bug
ClosedPublic

Authored by CaseyCarter on Jan 9 2023, 5:17 PM.

Details

Reviewers
var-const
philnik
Group Reviewers
Restricted Project
Commits
rG915f2f16fbb7: [libc++][test] Avoid MSVC constexpr bug
Summary

C++ constexpr allows a non-constant-expresssion lvalue to be used in a constant expression if it's not subject to lvalue-to-rvalue conversion. Subtly, this means you can make a constant-expression copy of a non-constant-expression object of empty type since the copy constructor doesn't perform lvalue-to-rvalue conversion. MSVC has had bugs with this usage forever, which will hopefully finally be mashed implementing C++23's relaxation on the use of pointers and references in constant expressions.

There's no need for this particular test to use this particular constexpr feature, we can simply make the predicates constant expressions.

Diff Detail

Event Timeline

CaseyCarter created this revision.Jan 9 2023, 5:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 5:17 PM
CaseyCarter requested review of this revision.Jan 9 2023, 5:17 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptJan 9 2023, 5:17 PM
philnik accepted this revision.Jan 9 2023, 5:31 PM
philnik added a subscriber: philnik.

I had no idea this is possible. LGTM.

This revision is now accepted and ready to land.Jan 9 2023, 5:31 PM
This revision was landed with ongoing or failed builds.Jan 9 2023, 5:48 PM
This revision was automatically updated to reflect the committed changes.