Skip to content

Commit d9f6f31

Browse files
authored
Adjust tests relying on CWG1351 noexcept behavior (#4914)
Update some noexcept tests in variant and invoke to remove old permissive behavior. This is guarded in a check for an as-yet unreleased MSVC compiler.
1 parent 8af2cc4 commit d9f6f31

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

tests/std/tests/P0088R3_variant/test.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ void test_const_lvalue_get() {
285285
{
286286
using V = std::variant<int, const long>;
287287
constexpr V v(42);
288-
static_assert(noexcept(std::get<0>(v)) == is_permissive);
288+
#if defined(_MSVC_INTERNAL_TESTING) || defined(__clang__) || defined(__EDG__) // TRANSITION, vs17.12p3
289+
ASSERT_NOT_NOEXCEPT(std::get<0>(v));
290+
#endif // ^^^ no workaround ^^^
289291
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
290292
static_assert(std::get<0>(v) == 42, "");
291293
}
@@ -299,7 +301,9 @@ void test_const_lvalue_get() {
299301
{
300302
using V = std::variant<int, const long>;
301303
constexpr V v(42l);
302-
static_assert(noexcept(std::get<1>(v)) == is_permissive);
304+
#if defined(_MSVC_INTERNAL_TESTING) || defined(__clang__) || defined(__EDG__) // TRANSITION, vs17.12p3
305+
ASSERT_NOT_NOEXCEPT(std::get<1>(v));
306+
#endif // ^^^ no workaround ^^^
303307
ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &);
304308
static_assert(std::get<1>(v) == 42, "");
305309
}
@@ -447,7 +451,9 @@ void test_const_lvalue_get() {
447451
{
448452
using V = std::variant<int, const long>;
449453
constexpr V v(42);
450-
static_assert(noexcept(std::get<int>(v)) == is_permissive);
454+
#if defined(_MSVC_INTERNAL_TESTING) || defined(__clang__) || defined(__EDG__) // TRANSITION, vs17.12p3
455+
ASSERT_NOT_NOEXCEPT(std::get<int>(v));
456+
#endif // ^^^ no workaround ^^^
451457
ASSERT_SAME_TYPE(decltype(std::get<int>(v)), const int &);
452458
static_assert(std::get<int>(v) == 42, "");
453459
}
@@ -461,7 +467,9 @@ void test_const_lvalue_get() {
461467
{
462468
using V = std::variant<int, const long>;
463469
constexpr V v(42l);
464-
static_assert(noexcept(std::get<const long>(v)) == is_permissive);
470+
#if defined(_MSVC_INTERNAL_TESTING) || defined(__clang__) || defined(__EDG__) // TRANSITION, vs17.12p3
471+
ASSERT_NOT_NOEXCEPT(std::get<const long>(v));
472+
#endif // ^^^ no workaround ^^^
465473
ASSERT_SAME_TYPE(decltype(std::get<const long>(v)), const long &);
466474
static_assert(std::get<const long>(v) == 42, "");
467475
}

tests/std/tests/P2136R3_invoke_r/test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ constexpr bool test_invoke_r() {
5050
static_assert(is_same_v<decltype(v2), double>);
5151
static_assert(is_void_v<decltype(invoke_r<void>(square, 1))>);
5252

53-
// TRANSITION, DevCom-1457457
54-
static_assert(noexcept(invoke_r<int>(square, 3)) == is_permissive);
55-
static_assert(noexcept(invoke(square, 3)) == is_permissive);
53+
#if defined(_MSVC_INTERNAL_TESTING) || defined(__clang__) || defined(__EDG__) // TRANSITION, vs17.12p3
54+
static_assert(!noexcept(invoke_r<int>(square, 3)));
55+
static_assert(!noexcept(invoke(square, 3)));
56+
#endif // ^^^ no workaround ^^^
5657

5758
constexpr bool has_noexcept_in_type =
5859
#ifdef __cpp_noexcept_function_type

0 commit comments

Comments
 (0)