From 508eecec8573930f3b520e4f231d359fc8f5927f Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 5 Dec 2025 18:23:20 +0800 Subject: [PATCH 1/2] Disallow specializing `bitset` and `ratio` --- stl/inc/bitset | 14 ++++++++++++-- stl/inc/ratio | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/stl/inc/bitset b/stl/inc/bitset index 9b8a247a6d1..06d1da21bfc 100644 --- a/stl/inc/bitset +++ b/stl/inc/bitset @@ -18,6 +18,12 @@ _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new +// TRANSITION, non-_Ugly attribute tokens +#pragma push_macro("msvc") +#pragma push_macro("no_specializations") +#undef msvc +#undef no_specializations + #ifndef _STD_BITSET_TO_STREAM_STACK_RESERVATION #define _STD_BITSET_TO_STREAM_STACK_RESERVATION 128 #endif // !defined(_STD_BITSET_TO_STREAM_STACK_RESERVATION) @@ -72,8 +78,8 @@ struct _Buffer_for_bitset<_Elem, _Bits, false> { _Elem _Buf[(_Bits != 0) ? _Bits : 1]; }; -_EXPORT_STD template -class bitset { // store fixed-length sequence of Boolean elements +_EXPORT_STD template // store fixed-length sequence of Boolean elements +class _NO_SPECIALIZATIONS_CITING("N5014 [namespace.std]/2.1") bitset { private: #pragma warning(push) #pragma warning(disable : 4296) // expression is always true (/Wall) @@ -687,6 +693,10 @@ struct hash> { }; _STD_END +// TRANSITION, non-_Ugly attribute tokens +#pragma pop_macro("no_specializations") +#pragma pop_macro("msvc") + #pragma pop_macro("new") _STL_RESTORE_CLANG_WARNINGS #pragma warning(pop) diff --git a/stl/inc/ratio b/stl/inc/ratio index 07117b684e5..3a303acb190 100644 --- a/stl/inc/ratio +++ b/stl/inc/ratio @@ -70,7 +70,7 @@ _NODISCARD constexpr intmax_t _Gcd(intmax_t _Ax, intmax_t _Bx) noexcept { } _EXPORT_STD template -struct ratio { // holds the ratio of _Nx to _Dx +struct _NO_SPECIALIZATIONS_CITING("N5014 [format.arg]/2.1") ratio { // holds the ratio of _Nx to _Dx static_assert(_Dx != 0, "zero denominator"); static_assert(-INTMAX_MAX <= _Nx, "numerator too negative"); static_assert(-INTMAX_MAX <= _Dx, "denominator too negative"); From 9fbfa895b4b06766a4d163f6e0623533c4508a4a Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 5 Dec 2025 13:36:33 -0800 Subject: [PATCH 2/2] Fix citation. --- stl/inc/ratio | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/ratio b/stl/inc/ratio index 3a303acb190..7d17b36e927 100644 --- a/stl/inc/ratio +++ b/stl/inc/ratio @@ -70,7 +70,7 @@ _NODISCARD constexpr intmax_t _Gcd(intmax_t _Ax, intmax_t _Bx) noexcept { } _EXPORT_STD template -struct _NO_SPECIALIZATIONS_CITING("N5014 [format.arg]/2.1") ratio { // holds the ratio of _Nx to _Dx +struct _NO_SPECIALIZATIONS_CITING("N5014 [namespace.std]/2.1") ratio { // holds the ratio of _Nx to _Dx static_assert(_Dx != 0, "zero denominator"); static_assert(-INTMAX_MAX <= _Nx, "numerator too negative"); static_assert(-INTMAX_MAX <= _Dx, "denominator too negative");