From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AECDA3857C51; Fri, 11 Nov 2022 20:46:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AECDA3857C51 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668199582; bh=UrgJR+6YgSlZ8n8mV2fgu4E4PEMZ+5BlAwYAQe6AQbE=; h=From:To:Subject:Date:From; b=UGyUiy/+M51MzZPUrbdHvMmETmG91bIR46KZCziGhgjfCYIJMlCbtdRFTrO0tLgcK 81ujU7XpVkCae/jK5YSY0hB2hFQVHWmOMwbDPLhM8JWUeE+Bf+ZQ2SVF1uXa6FYrNG esFYn8bK00FWrH3q78HmyfozRj/t9Z/0G6Qct+H4= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107649] New: New std::complex specializations are never used Date: Fri, 11 Nov 2022 20:46:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107649 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 we have: template requires(__complex_type<_Tp>::type) class complex<_Tp> { This partial specialization is never used. The constraint looks for a const= ant expression with true value, and none of the __complex_type specializations provide that. To test for a type name the constraint must be: template requires requires { typename __complex_type<_Tp>::type; } class complex<_Tp> { However if I fix this, so that the partial specialization is used for float= 64_t etc., then I get a cascade of errors for every overloaded function: include/complex: In instantiation of '_Tp std::abs(const complex<_Tp>&) [wi= th _Tp =3D _Float16]': testsuite/26_numerics/complex/ext_c++23.cc:28: required from 'void test_functions(T*, std::complex<_Tp>*) [with T =3D _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>&) [wi= th _Tp =3D _Float16]': testsuite/26_numerics/complex/ext_c++23.cc:29: required from 'void test_functions(T*, std::complex<_Tp>*) [with T =3D _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 =3D _Float16]': testsuite/26_numerics/complex/ext_c++23.cc:30: required from 'void test_functions(T*, std::complex<_Tp>*) [with T =3D _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 inline _Tp abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }=