[Bug 289103] The C++ code fails in clang and succeeds in gcc
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 26 Aug 2025 16:39:42 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=289103
Mark Millard <marklmi26-fbsd@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marklmi26-fbsd@yahoo.com
--- Comment #1 from Mark Millard <marklmi26-fbsd@yahoo.com> ---
The context here is libc++ vs. libstdc++, even using the
same compiler:
libc++ :
# g++15 -pedantic -Wall -std=c++23 -stdlib=libstdc++ main.cpp
you have mail
main.cpp: In function 'int main()':
main.cpp:180:29: warning: unused variable 'v1' [-Wunused-variable]
180 | rack::simd::float_4 v1;
| ^~
vs. libstdc++
# g++15 -pedantic -Wall -std=c++23 -stdlib=libc++ main.cpp
In file included from /usr/include/c++/v1/__math/exponential_functions.h:17,
from /usr/include/c++/v1/__math/hypot.h:15,
from /usr/include/c++/v1/cmath:316,
from /usr/include/c++/v1/complex:266,
from main.cpp:3:
/usr/include/c++/v1/__type_traits/promote.h: In instantiation of 'class
std::__1::__promote<rack::simd::Vector<float, 4>, float>':
/usr/include/c++/v1/complex:1110:74: required by substitution of
'template<class _Tp, class _Up, typename
std::__1::enable_if<std::__1::is_arithmetic<_A2>::value, int>::type <anonymous>
> std::__1::complex<typename std::__1::__promote<_A1, _A2>::type>
std::__1::pow(const complex<_Tp>&, const _Up&) [with _Tp =
rack::simd::Vector<float, 4>; _Up = float; typename
std::__1::enable_if<std::__1::is_arithmetic<_A2>::value, int>::type <anonymous>
= 0]'
1110 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp,
_Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) {
|
^~~
main.cpp:182:79: required from here
182 | rack::simd::float_4 globalSends =
rack::simd::pow<rack::simd::float_4>(globalSends,
globalAuxSendScalingExponent);
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/__type_traits/promote.h:32:40: error: static assertion
failed
32 | static_assert((is_arithmetic<_Args>::value && ...));
| ^~~~~
/usr/include/c++/v1/__type_traits/promote.h:32:40: note:
'std::__1::integral_constant<bool, false>::value' evaluates to false
/usr/include/c++/v1/__type_traits/promote.h:50:32: error: no matching function
for call to 'std::__1::__promote<rack::simd::Vector<float, 4>,
float>::__test(rack::simd::Vector<float, 4>)'
50 | using type = decltype((__test(_Args()) + ...));
| ~~~~~~^~~~~~~~~
/usr/include/c++/v1/__type_traits/promote.h:50:32: note: there are 12
candidates
/usr/include/c++/v1/__type_traits/promote.h:34:16: note: candidate 1: 'static
float std::__1::__promote<_Args>::__test(float) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
34 | static float __test(float);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:34:23: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to 'float'
34 | static float __test(float);
| ^~~~~
/usr/include/c++/v1/__type_traits/promote.h:35:17: note: candidate 2: 'static
double std::__1::__promote<_Args>::__test(char) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
35 | static double __test(char);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:35:24: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to 'char'
35 | static double __test(char);
| ^~~~
/usr/include/c++/v1/__type_traits/promote.h:36:17: note: candidate 3: 'static
double std::__1::__promote<_Args>::__test(int) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
36 | static double __test(int);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:36:24: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to 'int'
36 | static double __test(int);
| ^~~
/usr/include/c++/v1/__type_traits/promote.h:37:17: note: candidate 4: 'static
double std::__1::__promote<_Args>::__test(unsigned int) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
37 | static double __test(unsigned);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:37:24: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to 'unsigned int'
37 | static double __test(unsigned);
| ^~~~~~~~
/usr/include/c++/v1/__type_traits/promote.h:38:17: note: candidate 5: 'static
double std::__1::__promote<_Args>::__test(long int) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
38 | static double __test(long);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:38:24: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to 'long int'
38 | static double __test(long);
| ^~~~
/usr/include/c++/v1/__type_traits/promote.h:39:17: note: candidate 6: 'static
double std::__1::__promote<_Args>::__test(long unsigned int) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
39 | static double __test(unsigned long);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:39:24: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to 'long unsigned int'
39 | static double __test(unsigned long);
| ^~~~~~~~~~~~~
/usr/include/c++/v1/__type_traits/promote.h:40:17: note: candidate 7: 'static
double std::__1::__promote<_Args>::__test(long long int) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
40 | static double __test(long long);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:40:24: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to 'long long int'
40 | static double __test(long long);
| ^~~~~~~~~
/usr/include/c++/v1/__type_traits/promote.h:41:17: note: candidate 8: 'static
double std::__1::__promote<_Args>::__test(long long unsigned int) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
41 | static double __test(unsigned long long);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:41:24: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to 'long long unsigned int'
41 | static double __test(unsigned long long);
| ^~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/__type_traits/promote.h:43:17: note: candidate 9: 'static
double std::__1::__promote<_Args>::__test(__int128) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
43 | static double __test(__int128_t);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:43:24: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to '__int128'
43 | static double __test(__int128_t);
| ^~~~~~~~~~
/usr/include/c++/v1/__type_traits/promote.h:44:17: note: candidate 10: 'static
double std::__1::__promote<_Args>::__test(__int128 unsigned) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
44 | static double __test(__uint128_t);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:44:24: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to '__int128 unsigned'
44 | static double __test(__uint128_t);
| ^~~~~~~~~~~
/usr/include/c++/v1/__type_traits/promote.h:46:17: note: candidate 11: 'static
double std::__1::__promote<_Args>::__test(double) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
46 | static double __test(double);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:46:24: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to 'double'
46 | static double __test(double);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:47:22: note: candidate 12: 'static
long double std::__1::__promote<_Args>::__test(long double) [with _Args =
{rack::simd::Vector<float, 4>, float}]'
47 | static long double __test(long double);
| ^~~~~~
/usr/include/c++/v1/__type_traits/promote.h:47:29: note: no known conversion
for argument 1 from 'rack::simd::Vector<float, 4>' to 'long double'
47 | static long double __test(long double);
| ^~~~~~~~~~~
main.cpp: In function 'int main()':
main.cpp:180:29: warning: unused variable 'v1' [-Wunused-variable]
180 | rack::simd::float_4 v1;
| ^~
For reference:
# grep "#include" *.*pp
Vector.hpp:#include <cstring>
Vector.hpp:#include <pmmintrin.h>
main.cpp:#include <cstring>
main.cpp:#include <complex>
main.cpp:#include <pmmintrin.h>
main.cpp:#include <sys/types.h>
main.cpp:#include <math.h>
main.cpp:#include "Vector.hpp"
but on aarch64:
# g++15 -pedantic -Wall -std=c++23 -stdlib=libstdc++ main.cpp
main.cpp:4:10: fatal error: pmmintrin.h: No such file or directory
4 | #include <pmmintrin.h>
| ^~~~~~~~~~~~~
compilation terminated.
The program is far from meeting standard C++
criteria, using types the standard does not
support.
The code is libstdc++ specific. Do not
expect the source to be like a portable
C++ program for what contexts it will
compile and link in.
My view: Not a clang bug and not a libc++ bug.
Just a very toolchain-specific program.
--
You are receiving this mail because:
You are the assignee for the bug.