public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/107649] New: New std::complex specializations are never used
@ 2022-11-11 20:46 redi at gcc dot gnu.org
  2022-11-11 20:49 ` [Bug libstdc++/107649] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-11 20:46 UTC (permalink / raw)
  To: gcc-bugs

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()); }

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-11-28 22:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11 20:46 [Bug libstdc++/107649] New: New std::complex specializations are never used redi at gcc dot gnu.org
2022-11-11 20:49 ` [Bug libstdc++/107649] " redi at gcc dot gnu.org
2022-11-11 20:52 ` redi at gcc dot gnu.org
2022-11-12  8:29 ` jakub at gcc dot gnu.org
2022-11-12 12:34 ` redi at gcc dot gnu.org
2022-11-16 13:47 ` cvs-commit at gcc dot gnu.org
2022-11-17  0:36 ` redi at gcc dot gnu.org
2022-11-19 15:08 ` cvs-commit at gcc dot gnu.org
2022-11-28 22:32 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).