Skip to content

P0896R4_P1614R2_comparisons/test.cpp: Remove compiler bug workarounds #741

@StephanTLavavej

Description

@StephanTLavavej

The compiler bugs that we reported as Microsoft-internal VSO-905257 and VSO-1070391 were resolved as fixed in VS 2019 16.7 Preview 1. When that's available, we should remove the following workarounds in our tests:

#if defined(__clang__) || defined(__EDG__) // TRANSITION, VSO-905257
STATIC_ASSERT(test_compare_three_way<int, int, strong_ordering>());
STATIC_ASSERT(test_compare_three_way<int, long, strong_ordering>());
STATIC_ASSERT(test_compare_three_way<float, float, partial_ordering>());
STATIC_ASSERT(test_compare_three_way<float, double, partial_ordering>());
STATIC_ASSERT(test_compare_three_way<long, double, partial_ordering>());
STATIC_ASSERT(test_compare_three_way<bool, int, void>());
STATIC_ASSERT(test_compare_three_way<some_enum, some_enum, strong_ordering>());
STATIC_ASSERT(test_compare_three_way<some_enum, int, void>());
STATIC_ASSERT(test_compare_three_way<int*, int*, strong_ordering>());
STATIC_ASSERT(test_compare_three_way<int*, void*, strong_ordering>());
STATIC_ASSERT(test_compare_three_way<int (*)(), int (*)(), void>());
STATIC_ASSERT(test_compare_three_way<int (*)(), void (*)(), void>());
#endif // TRANSITION, VSO-905257

template <class T, class U, class R>
constexpr void assert_three_way(T const& t, U const& u, R const result) { // TRANSITION, VSO-905257
#if !defined(__clang__) && !defined(__EDG__)
// <=> expressions that resolve to builtin operators are incorrectly lvalues of const-qualified type on MSVC, so
// they are rejected by std::three_way_comparable and std::three_way_comparable_with.
if constexpr (!std::is_class_v<std::remove_cvref_t<T>> && !std::is_class_v<std::remove_cvref_t<U>>) {
return;
} else
#endif // !defined(__clang__) && !defined(__EDG__)
{
assert(compare_three_way{}(t, u) == result);
}
}

#if defined(__clang__) || defined(__EDG__) // TRANSITION, VSO-1070391
test_equality_comparable(&has_members::f, &has_members::g, strong_ordering::less); // Ditto "not equal"
#endif // TRANSITION, VSO-1070391

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedSomething works now, yay!testRelated to test code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions