diff --git a/stl/inc/compare b/stl/inc/compare index 76723bf8162..99e4a402cde 100644 --- a/stl/inc/compare +++ b/stl/inc/compare @@ -27,8 +27,19 @@ _STL_DISABLE_CLANG_WARNINGS #undef new _STD_BEGIN -using _Literal_zero = decltype(nullptr); -using _Compare_t = signed char; +void _Literal_zero_is_expected(); + +struct _Literal_zero { + template , int> = 0> + consteval _Literal_zero(_Ty _Zero) noexcept { + // Can't use _STL_VERIFY because this is a core header + if (_Zero != 0) { + _Literal_zero_is_expected(); + } + } +}; + +using _Compare_t = signed char; // These "pretty" enumerator names are safe since they reuse names of user-facing entities. enum class _Compare_eq : _Compare_t { equal = 0, equivalent = equal }; diff --git a/tests/std/tests/P0768R1_spaceship_operator/test.cpp b/tests/std/tests/P0768R1_spaceship_operator/test.cpp index 33a1218f7d6..00cfcc17a5c 100644 --- a/tests/std/tests/P0768R1_spaceship_operator/test.cpp +++ b/tests/std/tests/P0768R1_spaceship_operator/test.cpp @@ -7,6 +7,11 @@ #include #include +// See GH-3581 for details +#ifdef __clang__ +#pragma clang diagnostic error "-Wzero-as-null-pointer-constant" +#endif // __clang__ + enum class comp { equal, less, greater, unordered }; template