https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107649
Bug ID: 107649 Summary: New std::complex specializations are never used Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- In <complex> we have: template<typename _Tp> requires(__complex_type<_Tp>::type) class complex<_Tp> { This partial specialization is never used. The constraint looks for a constant expression with true value, and none of the __complex_type specializations provide that. To test for a type name the constraint must be: template<typename _Tp> requires requires { typename __complex_type<_Tp>::type; } class complex<_Tp> { However if I fix this, so that the partial specialization is used for float64_t etc., then I get a cascade of errors for every overloaded <math.h> function: include/complex: In instantiation of '_Tp std::abs(const complex<_Tp>&) [with _Tp = _Float16]': testsuite/26_numerics/complex/ext_c++23.cc:28: required from 'void test_functions(T*, std::complex<_Tp>*) [with T = _Float16]' testsuite/26_numerics/complex/ext_c++23.cc:56: required from here include/complex:629: error: call of overloaded '__complex_abs(std::complex<_Float16>::_ComplexT)' is ambiguous include/complex:618: note: candidate: 'float std::__complex_abs(__complex__ float)' include/complex:621: note: candidate: 'double std::__complex_abs(__complex__ double)' include/complex:624: note: candidate: 'long double std::__complex_abs(const __complex__ long double&)' include/complex: In instantiation of '_Tp std::arg(const complex<_Tp>&) [with _Tp = _Float16]': testsuite/26_numerics/complex/ext_c++23.cc:29: required from 'void test_functions(T*, std::complex<_Tp>*) [with T = _Float16]' testsuite/26_numerics/complex/ext_c++23.cc:56: required from here include/complex:656: error: call of overloaded '__complex_arg(std::complex<_Float16>::_ComplexT)' is ambiguous include/complex:645: note: candidate: 'float std::__complex_arg(__complex__ float)' include/complex:648: note: candidate: 'double std::__complex_arg(__complex__ double)' include/complex:651: note: candidate: 'long double std::__complex_arg(const __complex__ long double&)' include/complex: In instantiation of 'std::complex<_Tp> std::cos(const complex<_Tp>&) [with _Tp = _Float16]': testsuite/26_numerics/complex/ext_c++23.cc:30: required from 'void test_functions(T*, std::complex<_Tp>*) [with T = _Float16]' testsuite/26_numerics/complex/ext_c++23.cc:56: required from here This is because with the fix to the speclization, __rep() now returns a __complex__ T and so we try to call one of the float/double/longdouble overloads: inline float __complex_abs(__complex__ float __z) { return __builtin_cabsf(__z); } inline double __complex_abs(__complex__ double __z) { return __builtin_cabs(__z); } inline long double __complex_abs(const __complex__ long double& __z) { return __builtin_cabsl(__z); } template<typename _Tp> inline _Tp abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }