Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard Library Modules: Add compiler workarounds for <random> #4906

Merged
merged 4 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stl/inc/__msvc_int128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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} {}
Expand Down Expand Up @@ -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} {}
Expand Down
8 changes: 8 additions & 0 deletions tests/std/include/test_header_units_and_modules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double, 53>(lcg);
assert(val >= 0.0);
assert(val < 1.0);
#endif // ^^^ no workaround ^^^
}

void test_ranges() {
Expand Down