From 9ae6a0da48967c43b534681da28bf001804fa951 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 1 Jan 2026 21:24:09 +0200 Subject: [PATCH 1/6] Remove non-floating complex --- stl/inc/complex | 11 +++++++++++ stl/inc/yvals_core.h | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/stl/inc/complex b/stl/inc/complex index acd727f40c6..bbf1e30493d 100644 --- a/stl/inc/complex +++ b/stl/inc/complex @@ -1322,6 +1322,16 @@ constexpr complex::complex(const complex& _Right) noexcept / constexpr complex::complex(const complex& _Right) noexcept // strengthened : _Complex_base(_Right.real(), _Right.imag()) {} +#if !_HAS_NONFLOATING_COMPLEX +_EXPORT_STD template +class complex{ + static_assert(_Always_false<_Ty>, + "The effect of instantiating the template std::complex for any type other than float, double, or long double " + "is unspecified. The possibility of such instantiation will be removed in a future version. " + "You can define _HAS_NONFLOATING_COMPLEX to 1 to enable such instantiation " + "and define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress its deprecation warning."); +}; +#else // ^^^ _HAS_NONFLOATING_COMPLEX / _HAS_NONFLOATING_COMPLEX vvv _EXPORT_STD template class complex : public _Complex_base<_Ty, _Complex_value<_Ty>> { public: @@ -1413,6 +1423,7 @@ public: return *this; } }; +#endif // ^^^ _HAS_NONFLOATING_COMPLEX ^^^ _EXPORT_STD template _NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const complex<_Ty>& _Left, const complex<_Ty>& _Right) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index ea67cde8d2a..76fc411949b 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -952,6 +952,10 @@ _EMIT_STL_ERROR(STL1001, "Unexpected compiler version, expected MSVC Compiler 19 #error /GR implies _HAS_STATIC_RTTI. #endif // defined(_CPPRTTI) && !_HAS_STATIC_RTTI +#ifndef _HAS_NONFLOATING_COMPLEX +#define _HAS_NONFLOATING_COMPLEX 0 +#endif // !defined(_HAS_NONFLOATING_COMPLEX) + // N4950 [dcl.constexpr]/1: "A function or static data member declared with the // constexpr or consteval specifier is implicitly an inline function or variable" @@ -1417,6 +1421,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect #define _CXX20_REMOVE_CISO646 #endif // ^^^ warning disabled ^^^ +#if _HAS_NONFLOATING_COMPLEX #if !defined(_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING) #define _DEPRECATE_NONFLOATING_COMPLEX \ [[deprecated("warning STL4037: " \ @@ -1427,6 +1432,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect #else // ^^^ warning enabled / warning disabled vvv #define _DEPRECATE_NONFLOATING_COMPLEX #endif // ^^^ warning disabled ^^^ +#endif // ^^^ _HAS_NONFLOATING_COMPLEX ^^^ // STL4038 is used to warn that "The contents of are available only with C++NN or later." From b16031826c8721e3c49e84d1f5cc6a91e1ad6c30 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 1 Jan 2026 21:32:45 +0200 Subject: [PATCH 2/6] Escape hatch for libc++ tests --- tests/libcxx/usual_matrix.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/libcxx/usual_matrix.lst b/tests/libcxx/usual_matrix.lst index 73a362feafd..ce02482cf66 100644 --- a/tests/libcxx/usual_matrix.lst +++ b/tests/libcxx/usual_matrix.lst @@ -3,7 +3,7 @@ RUNALL_INCLUDE ..\universal_prefix.lst RUNALL_CROSSLIST -* PM_CL="/EHsc /MTd /std:c++latest /permissive- /utf-8 /FImsvc_stdlib_force_include.h /wd4643" +* PM_CL="/EHsc /MTd /std:c++latest /permissive- /utf-8 /FImsvc_stdlib_force_include.h /wd4643 /D_HAS_NONFLOATING_COMPLEX=1" RUNALL_CROSSLIST PM_CL="/Zc:preprocessor" ASAN PM_CL="-fsanitize=address /Zi" PM_LINK="/debug" From ceafe14c5661341e172a1f29586986f7a1923798 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 1 Jan 2026 21:52:13 +0200 Subject: [PATCH 3/6] formatting fix --- stl/inc/complex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/complex b/stl/inc/complex index bbf1e30493d..682529be3af 100644 --- a/stl/inc/complex +++ b/stl/inc/complex @@ -1324,7 +1324,7 @@ constexpr complex::complex(const complex& _Right) noexcept #if !_HAS_NONFLOATING_COMPLEX _EXPORT_STD template -class complex{ +class complex { static_assert(_Always_false<_Ty>, "The effect of instantiating the template std::complex for any type other than float, double, or long double " "is unspecified. The possibility of such instantiation will be removed in a future version. " From 1f5e58dbdfcfc3d0361a1b951d633baf62486e4b Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 1 Jan 2026 22:27:11 +0200 Subject: [PATCH 4/6] It is deduction, Watson! --- stl/inc/complex | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stl/inc/complex b/stl/inc/complex index 682529be3af..fe58ac73db2 100644 --- a/stl/inc/complex +++ b/stl/inc/complex @@ -1330,6 +1330,13 @@ class complex { "is unspecified. The possibility of such instantiation will be removed in a future version. " "You can define _HAS_NONFLOATING_COMPLEX to 1 to enable such instantiation " "and define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress its deprecation warning."); + + // Keep constructors for deduction + + constexpr complex(const _Ty& = _Ty(), const _Ty& = _Ty()) {} + + template + constexpr complex(const complex<_Other>&) {} }; #else // ^^^ _HAS_NONFLOATING_COMPLEX / _HAS_NONFLOATING_COMPLEX vvv _EXPORT_STD template From 4f7419353073bf4536cf5b7f59b06edc08892a54 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 2 Jan 2026 11:20:06 +0200 Subject: [PATCH 5/6] Let's even delete them --- stl/inc/complex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/inc/complex b/stl/inc/complex index fe58ac73db2..4df724481c9 100644 --- a/stl/inc/complex +++ b/stl/inc/complex @@ -1331,12 +1331,12 @@ class complex { "You can define _HAS_NONFLOATING_COMPLEX to 1 to enable such instantiation " "and define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress its deprecation warning."); - // Keep constructors for deduction + // For deduction, primary template is used, so keeping couple of constructor around - constexpr complex(const _Ty& = _Ty(), const _Ty& = _Ty()) {} + constexpr complex(const _Ty& = _Ty(), const _Ty& = _Ty()) = delete; template - constexpr complex(const complex<_Other>&) {} + constexpr complex(const complex<_Other>&) = delete; }; #else // ^^^ _HAS_NONFLOATING_COMPLEX / _HAS_NONFLOATING_COMPLEX vvv _EXPORT_STD template From 0351a2c161e1b39544cbca23e6719095608b1426 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 2 Jan 2026 16:17:38 +0200 Subject: [PATCH 6/6] typos --- stl/inc/complex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/complex b/stl/inc/complex index 4df724481c9..3f680159153 100644 --- a/stl/inc/complex +++ b/stl/inc/complex @@ -1331,14 +1331,14 @@ class complex { "You can define _HAS_NONFLOATING_COMPLEX to 1 to enable such instantiation " "and define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress its deprecation warning."); - // For deduction, primary template is used, so keeping couple of constructor around + // For deduction, primary template is used, so keeping couple of constructors around constexpr complex(const _Ty& = _Ty(), const _Ty& = _Ty()) = delete; template constexpr complex(const complex<_Other>&) = delete; }; -#else // ^^^ _HAS_NONFLOATING_COMPLEX / _HAS_NONFLOATING_COMPLEX vvv +#else // ^^^ !_HAS_NONFLOATING_COMPLEX / _HAS_NONFLOATING_COMPLEX vvv _EXPORT_STD template class complex : public _Complex_base<_Ty, _Complex_value<_Ty>> { public: