This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] std::get<0>([std::variant constant expression]) *is* noexcept
ClosedPublic

Authored by CaseyCarter on Dec 5 2016, 5:22 PM.

Details

Summary

noexcept(foo) is true when foo is a constant expression.

Diff Detail

Event Timeline

CaseyCarter updated this revision to Diff 80351.Dec 5 2016, 5:22 PM
CaseyCarter retitled this revision from to [libcxx] [test] std::get<0>([std::variant constant expression]) *is* noexcept.
CaseyCarter updated this object.
CaseyCarter added reviewers: EricWF, mclow.lists.
CaseyCarter added a subscriber: cfe-commits.
CaseyCarter added inline comments.
test/std/utilities/variant/variant.get/get_index.pass.cpp
39–41

THAT'S RIGHT, A CLANG BUG (https://llvm.org/bugs/show_bug.cgi?id=15481) THAT C1XX GETS CORRECT. You saw it here first.

STL_MSFT edited edge metadata.Dec 5 2016, 5:44 PM

I also saw get_type.pass.cpp failing.

I would recommend commenting the ifndef with the clang bug URL you found.

EricWF accepted this revision.Dec 5 2016, 5:49 PM
EricWF edited edge metadata.
EricWF added inline comments.
test/std/utilities/variant/variant.get/get_index.pass.cpp
39–41

Ha A clang bug indeed! Although IDK how sane the other behavior is, specifically:

constexpr bool foo() noexcept(false) { return true; }
static_assert(!noexcept(foo()));

This part of the change LGTM, but could you also add a test that the function is not noexcept when it cannot do constant evaluation?

This revision is now accepted and ready to land.Dec 5 2016, 5:49 PM
CaseyCarter updated this revision to Diff 80365.Dec 5 2016, 6:34 PM
CaseyCarter edited edge metadata.

Address review comments:

  • Annotate the clang bug which the conditional compilation is avoiding.
  • Assure the expression in question is not noexcept when not a constant expression.
  • Cover get_type
mclow.lists accepted this revision.Dec 5 2016, 10:48 PM
mclow.lists edited edge metadata.

I'd appreciate it if someone made a note to revisit this test when the clang bug is fixed, and change the #ifndef __clang__ to something like #ifndef __clang__ || clang_version < XXXX".

This LGTM.

STL_MSFT accepted this revision.Dec 8 2016, 11:57 AM
STL_MSFT edited edge metadata.
CaseyCarter closed this revision.Dec 8 2016, 4:25 PM
CaseyCarter marked an inline comment as done.