Opened 7 days ago

Last modified 3 days ago

#71272 new defect

legacy-support breaks a valid code: error: no match for 'operator*' (operand types are 'double' and 'std::complex<float>')

Reported by: barracuda156 Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.10.4
Keywords: Cc: macportsraf, fhgwright (Fred Wright), kencu (Ken), mascguy (Christopher Nielsen)
Port: legacy-support-devel

Description

Take a look at this issue with scipy: https://github.com/scipy/scipy/issues/21826

Wasting a lot of time, both of scipy upstream and my own, I finally dug this out: it is legacysupport breaking this. Specifically, identical command errs out with legacysupport headers, but compiles normally without it:

36-50% sudo   /opt/local/bin/g++-mp-14 -I/opt/local/include/LegacySupport -Iscipy/special/_special_ufuncs.cpython-311-darwin.so.p -Iscipy/special -I../scipy/special -Iscipy/_lib -I../scipy/_lib -I../scipy/_build_utils/src -I../../../../../../../../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/numpy/core/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -fvisibility=hidden -fvisibility-inlines-hidden -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=gnu++17 -O3 -D_GLIBCXX_USE_CXX11_ABI=0 -isysroot/ -DSP_SPECFUN_ERROR -DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION -MD -MQ scipy/special/_special_ufuncs.cpython-311-darwin.so.p/_special_ufuncs.cpp.o -MF scipy/special/_special_ufuncs.cpython-311-darwin.so.p/_special_ufuncs.cpp.o.d -o scipy/special/_special_ufuncs.cpython-311-darwin.so.p/_special_ufuncs.cpp.o -c ../scipy/special/_special_ufuncs.cpp
In file included from ../scipy/special/special/specfun.h:4,
                 from ../scipy/special/special.h:6,
                 from ../scipy/special/_special_ufuncs.cpp:7:
../scipy/special/special/specfun/specfun.h: In instantiation of 'std::complex<_Tp> special::specfun::e1z(std::complex<_Tp>) [with T = float]':
../scipy/special/special/expint.h:17:40:   required from 'std::complex<_Tp> special::exp1(std::complex<_Tp>) [with T = float]'
   17 |     std::complex<T> outz = specfun::e1z(z);
      |                            ~~~~~~~~~~~~^~~
../scipy/special/_special_ufuncs.cpp:304:47:   required from here
  304 |          static_cast<func_F_F_t>(special::exp1), static_cast<func_D_D_t>(special::exp1)},
      |                                               ^
../scipy/special/special/specfun/specfun.h:2099:70: error: no match for 'operator*' (operand types are 'double' and 'std::complex<float>')
 2099 |             ce1 = -el - std::log(-z) + z*ce1 - copysign(pi, z.imag())*std::complex<T>(0.0, 1.0);
      |                                                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../scipy/special/special/error.h:27,
                 from ../scipy/special/sf_error_state.h:4,
                 from ../scipy/special/sf_error.h:3,
                 from ../scipy/special/ufunc.h:17,
                 from ../scipy/special/_special_ufuncs.cpp:1:
/opt/local/include/gcc14/c++/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)'
  400 |     operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/opt/local/include/gcc14/c++/complex:400:5: note:   template argument deduction/substitution failed:
../scipy/special/special/specfun/specfun.h:2099:70: note:   mismatched types 'const std::complex<_Tp>' and 'double'
 2099 |             ce1 = -el - std::log(-z) + z*ce1 - copysign(pi, z.imag())*std::complex<T>(0.0, 1.0);
      |                                                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/gcc14/c++/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)'
  409 |     operator*(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/opt/local/include/gcc14/c++/complex:409:5: note:   template argument deduction/substitution failed:
../scipy/special/special/specfun/specfun.h:2099:70: note:   mismatched types 'const std::complex<_Tp>' and 'double'
 2099 |             ce1 = -el - std::log(-z) + z*ce1 - copysign(pi, z.imag())*std::complex<T>(0.0, 1.0);
      |                                                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/gcc14/c++/complex:418:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)'
  418 |     operator*(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/opt/local/include/gcc14/c++/complex:418:5: note:   template argument deduction/substitution failed:
../scipy/special/special/specfun/specfun.h:2099:70: note:   deduced conflicting types for parameter '_Tp' ('double' and 'float')
 2099 |             ce1 = -el - std::log(-z) + z*ce1 - copysign(pi, z.imag())*std::complex<T>(0.0, 1.0);
      |                                                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
36-50% sudo   /opt/local/bin/g++-mp-14 -Iscipy/special/_special_ufuncs.cpython-311-darwin.so.p -Iscipy/special -I../scipy/special -Iscipy/_lib -I../scipy/_lib -I../scipy/_build_utils/src -I../../../../../../../../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/numpy/core/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -fvisibility=hidden -fvisibility-inlines-hidden -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=gnu++17 -O3 -D_GLIBCXX_USE_CXX11_ABI=0 -isysroot/ -DSP_SPECFUN_ERROR -DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION -MD -MQ scipy/special/_special_ufuncs.cpython-311-darwin.so.p/_special_ufuncs.cpp.o -MF scipy/special/_special_ufuncs.cpython-311-darwin.so.p/_special_ufuncs.cpp.o.d -o scipy/special/_special_ufuncs.cpython-311-darwin.so.p/_special_ufuncs.cpp.o -c ../scipy/special/_special_ufuncs.cpp

36-50%

Since spicy port uses legacysupport PG, it gets passed via environment, and that breaks the build here.

Change History (3)

comment:1 Changed 7 days ago by barracuda156

Just in case, defining __MP_LEGACY_SUPPORT_CXX11_CMATH__ to 0 or 1 (via MacportsLegacySupport.h) does not change the error.

comment:2 Changed 7 days ago by mascguy (Christopher Nielsen)

Cc: mascguy added

comment:3 Changed 3 days ago by fhgwright (Fred Wright)

I'll take a look at it, though it looks like you have a workaround for now, in 88744d447d0. IMO, any build system that requires a patch that complicated just to apply options selectively is broken. Admittedly, make is broken by that definition.

So far, I haven't touched any of the C++ math stuff, and from what I can see from the "tests", it looks pretty ugly.

If it's only observed on 10.6 ppc and scipy can't be built with Rosetta, then it may not be possible to reproduce it here, unless it can be done by overriding the compiler selection (which probably isn't gcc by default on x86).

Note: See TracTickets for help on using tickets.