From 138e1161c995209afb9644d87beb7f5e33747d38 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 25 Aug 2024 12:22:04 -0700 Subject: [PATCH] Standard Library Modules: Add compiler workarounds for `` (#4906) --- stl/inc/__msvc_int128.hpp | 8 ++++---- tests/std/include/test_header_units_and_modules.hpp | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/stl/inc/__msvc_int128.hpp b/stl/inc/__msvc_int128.hpp index cef5bd87c0..9a3f2e3c69 100644 --- a/stl/inc/__msvc_int128.hpp +++ b/stl/inc/__msvc_int128.hpp @@ -707,9 +707,9 @@ struct _Unsigned128 : _Base128 { using _Signed_type = _Signed128; using _Unsigned_type = _Unsigned128; -#if !_HAS_CXX17 +#if !_HAS_CXX17 || (_HAS_CXX20 && !defined(__clang__) && !defined(__EDG__)) // TRANSITION, DevCom-10729775 constexpr _Unsigned128() noexcept : _Base128{} {} -#endif // !_HAS_CXX17 +#endif // ^^^ workaround for C++20 MSVC modules and header units; should be guarded for !_HAS_CXX17 only ^^^ using _Base128::_Base128; constexpr explicit _Unsigned128(const _Base128& _That) noexcept : _Base128{_That} {} @@ -1024,9 +1024,9 @@ struct _Signed128 : _Base128 { using _Signed_type = _Signed128; using _Unsigned_type = _Unsigned128; -#if !_HAS_CXX17 +#if !_HAS_CXX17 || (_HAS_CXX20 && !defined(__clang__) && !defined(__EDG__)) // TRANSITION, DevCom-10729775 constexpr _Signed128() noexcept : _Base128{} {} -#endif // !_HAS_CXX17 +#endif // ^^^ workaround for C++20 MSVC modules and header units; should be guarded for !_HAS_CXX17 only ^^^ using _Base128::_Base128; constexpr explicit _Signed128(const _Base128& _That) noexcept : _Base128{_That} {} diff --git a/tests/std/include/test_header_units_and_modules.hpp b/tests/std/include/test_header_units_and_modules.hpp index ceab5eb2d5..c37a517303 100644 --- a/tests/std/include/test_header_units_and_modules.hpp +++ b/tests/std/include/test_header_units_and_modules.hpp @@ -593,6 +593,14 @@ void test_random() { minstd_rand0 lcg; lcg.discard(9999); assert(lcg() == 1043618065); // N4868 [rand.predef]/1 + +#ifndef _MSVC_INTERNAL_TESTING // TRANSITION, VSO-2226569 + // Test coverage for GH-4899 "Standard Library Modules: uniform_real_distribution emits + // error C2512: 'std::_Unsigned128': no appropriate default constructor available": + const double val = generate_canonical(lcg); + assert(val >= 0.0); + assert(val < 1.0); +#endif // ^^^ no workaround ^^^ } void test_ranges() {