stan-dev / math

The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
752 stars 188 forks source link

Compilation failures under LLVM 19 #3106

Closed WardBrian closed 1 month ago

WardBrian commented 1 month ago

Description

LLVM 19.1.0 was released last week: https://discourse.llvm.org/t/llvm-19-1-0-released/81285

Running our test pipeline uncovered some failures: https://jenkins.flatironinstitute.org/blue/organizations/jenkins/Stan%2FBleedingEdgeCompilersMonthly/detail/BleedingEdgeCompilersMonthly/198/pipeline/207

Example

Details

``` In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote>' requested here 1116 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const _Tp& __x, const complex<_Up>& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:275:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = int, _Up = stan::math::var_value, $2 = (no value)] 275 | auto a5 = pow(i, cv); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote>' requested here 1116 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const _Tp& __x, const complex<_Up>& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:281:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = double, _Up = stan::math::var_value, $2 = (no value)] 281 | auto b5 = pow(d, cv); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote, int>' requested here 1110 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const complex<_Tp>& __x, const _Up& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:295:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::var_value, _Up = int, $2 = (no value)] 295 | auto d1 = pow(cv, i); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote, double>' requested here 1110 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const complex<_Tp>& __x, const _Up& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:296:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::var_value, _Up = double, $2 = (no value)] 296 | auto d2 = pow(cv, d); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1103:47: note: in instantiation of template class 'std::__promote, stan::math::var_value>' requested here 1103 | inline _LIBCPP_HIDE_FROM_ABI complex::type> | ^ test/unit/math/mix/fun_16_test.cpp:299:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::var_value, _Up = stan::math::var_value] 299 | auto d5 = pow(cv, cv); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote>' requested here 1116 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const _Tp& __x, const complex<_Up>& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:321:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = int, _Up = stan::math::fvar, $2 = (no value)] 321 | auto a5 = pow(i, cv); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote>' requested here 1116 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const _Tp& __x, const complex<_Up>& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:327:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = double, _Up = stan::math::fvar, $2 = (no value)] 327 | auto b5 = pow(d, cv); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote, int>' requested here 1110 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const complex<_Tp>& __x, const _Up& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:335:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::fvar, _Up = int, $2 = (no value)] 335 | auto d1 = pow(cv, i); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote, double>' requested here 1110 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const complex<_Tp>& __x, const _Up& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:336:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::fvar, _Up = double, $2 = (no value)] 336 | auto d2 = pow(cv, d); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1103:47: note: in instantiation of template class 'std::__promote, stan::math::fvar>' requested here 1103 | inline _LIBCPP_HIDE_FROM_ABI complex::type> | ^ test/unit/math/mix/fun_16_test.cpp:339:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::fvar, _Up = stan::math::fvar] 339 | auto d5 = pow(cv, cv); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote>, int>' requested here 1110 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const complex<_Tp>& __x, const _Up& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:163:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::fvar>, _Up = int, $2 = (no value)] 163 | auto a2 = pow(std::complex(1.0), 1); | ^ test/unit/math/mix/fun_16_test.cpp:179:3: note: in instantiation of function template specialization 'expect_arith_instantiate>>' requested here 179 | expect_arith_instantiate>>(); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote>, double>' requested here 1110 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const complex<_Tp>& __x, const _Up& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:164:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::fvar>, _Up = double, $2 = (no value)] 164 | auto b2 = pow(std::complex(1.0), 1.0); | ^ test/unit/math/mix/fun_16_test.cpp:179:3: note: in instantiation of function template specialization 'expect_arith_instantiate>>' requested here 179 | expect_arith_instantiate>>(); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote>>' requested here 1116 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const _Tp& __x, const complex<_Up>& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:165:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = int, _Up = stan::math::fvar>, $2 = (no value)] 165 | auto c2 = pow(1, std::complex(1.0)); | ^ test/unit/math/mix/fun_16_test.cpp:179:3: note: in instantiation of function template specialization 'expect_arith_instantiate>>' requested here 179 | expect_arith_instantiate>>(); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote>>' requested here 1116 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const _Tp& __x, const complex<_Up>& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:166:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = double, _Up = stan::math::fvar>, $2 = (no value)] 166 | auto d2 = pow(1.0, std::complex(1.0)); | ^ test/unit/math/mix/fun_16_test.cpp:179:3: note: in instantiation of function template specialization 'expect_arith_instantiate>>' requested here 179 | expect_arith_instantiate>>(); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1103:47: note: in instantiation of template class 'std::__promote>, stan::math::fvar>>' requested here 1103 | inline _LIBCPP_HIDE_FROM_ABI complex::type> | ^ test/unit/math/mix/fun_16_test.cpp:167:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::fvar>, _Up = stan::math::fvar>] 167 | auto e2 = pow(std::complex(1.0), std::complex(1.0)); | ^ test/unit/math/mix/fun_16_test.cpp:179:3: note: in instantiation of function template specialization 'expect_arith_instantiate>>' requested here 179 | expect_arith_instantiate>>(); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote>, int>' requested here 1110 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const complex<_Tp>& __x, const _Up& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:163:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::fvar>, _Up = int, $2 = (no value)] 163 | auto a2 = pow(std::complex(1.0), 1); | ^ test/unit/math/mix/fun_16_test.cpp:180:3: note: in instantiation of function template specialization 'expect_arith_instantiate>>' requested here 180 | expect_arith_instantiate>(); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote>, double>' requested here 1110 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const complex<_Tp>& __x, const _Up& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:164:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = stan::math::fvar>, _Up = double, $2 = (no value)] 164 | auto b2 = pow(std::complex(1.0), 1.0); | ^ test/unit/math/mix/fun_16_test.cpp:180:3: note: in instantiation of function template specialization 'expect_arith_instantiate>>' requested here 180 | expect_arith_instantiate>(); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote>>' requested here 1116 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const _Tp& __x, const complex<_Up>& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:165:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = int, _Up = stan::math::fvar>, $2 = (no value)] 165 | auto c2 = pow(1, std::complex(1.0)); | ^ test/unit/math/mix/fun_16_test.cpp:180:3: note: in instantiation of function template specialization 'expect_arith_instantiate>>' requested here 180 | expect_arith_instantiate>(); | ^ In file included from test/unit/math/mix/fun_16_test.cpp:1: In file included from ./test/unit/math/test_ad.hpp:4: In file included from ./stan/math/mix.hpp:4: In file included from ./stan/math/mix/meta.hpp:6: In file included from ./stan/math/fwd/core.hpp:4: In file included from ./stan/math/fwd/core/fvar.hpp:4: In file included from ./stan/math/prim/meta.hpp:72: In file included from ./stan/math/prim/meta/append_return_type.hpp:4: In file included from ./stan/math/prim/fun/Eigen.hpp:22: In file included from lib/eigen_3.4.0/Eigen/Dense:1: In file included from lib/eigen_3.4.0/Eigen/Core:19: In file included from lib/eigen_3.4.0/Eigen/src/Core/util/Macros.h:679: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote>>' requested here 1116 | inline _LIBCPP_HIDE_FROM_ABI complex::type> pow(const _Tp& __x, const complex<_Up>& __y) { | ^ test/unit/math/mix/fun_16_test.cpp:166:13: note: while substituting deduced template arguments into function template 'pow' [with _Tp = double, _Up = stan::math::fvar>, $2 = (no value)] 166 | auto d2 = pow(1.0, std::complex(1.0)); | ^ test/unit/math/mix/fun_16_test.cpp:180:3: note: in instantiation of function template specialization 'expect_arith_instantiate>>' requested here 180 | expect_arith_instantiate>(); | ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. ```

Expected Output

Compilation to succeed

It smells like #3006 may be related again, it looks like these asserts are in the complex functions

Current Version:

v4.9.0

WardBrian commented 1 month ago

Looks like this static assert was introduced by https://github.com/llvm/llvm-project/pull/81379

WardBrian commented 1 month ago

@SteveBronder @andrjohns are you able to take a look at this? It will become a blocker for the upcoming release I think!

WardBrian commented 1 month ago

It appears the issue is specifically with mixing a complex value of our autodiff types with a primitive in pow()

SteveBronder commented 1 month ago

The actual error in details it comes from here.

template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Up>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) {
  typedef complex<typename __promote<_Tp, _Up>::type> result_type;
  return std::pow(result_type(__x), result_type(__y));
}

and the offending code in the tests is calling a complex<var> and double

auto d2 = pow(cv, d);

which should be calling the stan pow function from here

/**
 * Return the first argument raised to the power of the second argument.
 *
 * @tparam T arithmetic type
 * @param x first argument
 * @param y second argument
 * @return first argument to the power of the second argument
 */
template <typename T, typename = require_arithmetic_t<T>>
inline std::complex<var> pow(const std::complex<var>& x, T y) {
  return internal::complex_pow(x, y);
}

We could make ours a more likely candidate by making T info const T&, but I think that just kicks the can down the line. I'm going to file an issue with them about this but for now I think your #3109 is the right answer

SteveBronder commented 1 month ago

Hmm, actually maybe we should just make our T, const T& since all of their signatures are const T&. I don't have 19.0.1 locally but that would solve the problem.

WardBrian commented 1 month ago

For testing I can pull the docker image we use, if there’s something you’d rather me try

SteveBronder commented 1 month ago

Yes I think that's right because the standard has the pow signature using const &

https://en.cppreference.com/w/cpp/numeric/complex/pow

SteveBronder commented 1 month ago

Can you try changing the signature I linked above to be

template <typename T, typename = require_arithmetic_t<T>>
inline std::complex<var> pow(const std::complex<var>& x, const T& y) {
  return internal::complex_pow(x, y);
}
WardBrian commented 1 month ago

@SteveBronder it looks like this model also fails, due to the apply_scalar overload calling pow instead of stan::math::pow.

Details

``` n file included from pow.hpp:1: In file included from /home/jenkins/cmdstan/stan/src/stan/model/model_header.hpp:4: In file included from /home/jenkins/cmdstan/stan/src/stan/model/model_base.hpp:7: In file included from /home/jenkins/cmdstan/stan/src/stan/io/var_context.hpp:4: In file included from /usr/local/include/c++/v1/sstream:317: In file included from /usr/local/include/c++/v1/__ostream/basic_ostream.h:16: In file included from /usr/local/include/c++/v1/__system_error/error_code.h:18: In file included from /usr/local/include/c++/v1/__system_error/error_category.h:15: In file included from /usr/local/include/c++/v1/string:614: In file included from /usr/local/include/c++/v1/__memory_resource/polymorphic_allocator.h:20: In file included from /usr/local/include/c++/v1/tuple:268: In file included from /usr/local/include/c++/v1/compare:174: In file included from /usr/local/include/c++/v1/cmath:316: In file included from /usr/local/include/c++/v1/__math/hypot.h:15: In file included from /usr/local/include/c++/v1/__math/exponential_functions.h:17: /usr/local/include/c++/v1/__type_traits/promote.h:32:18: error: static assertion failed due to requirement 'is_arithmetic>::value' 32 | static_assert((is_arithmetic<_Args>::value && ...)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/v1/complex:1103:47: note: in instantiation of template class 'std::__promote>' requested here 1103 | inline _LIBCPP_HIDE_FROM_ABI complex::type> | ^ /home/jenkins/cmdstan/stan/lib/stan_math/stan/math/prim/fun/pow.hpp:66:12: note: while substituting deduced template arguments into function template 'pow' [with _Tp = double, _Up = stan::math::var_value] 66 | return pow(c, d); | ^ /home/jenkins/cmdstan/stan/lib/stan_math/stan/math/prim/functor/apply_scalar_binary.hpp:290:42: note: in instantiation of function template specialization 'stan::math::pow(const std::vector> &, const std::complex &)::(anonymous class)::operator(), std::complex>' requested here 290 | using T_return = std::decay_t; | ^ /home/jenkins/cmdstan/stan/lib/stan_math/stan/math/prim/fun/pow.hpp:64:10: note: in instantiation of function template specialization 'stan::math::apply_scalar_binary>, std::complex, (lambda at /home/jenkins/cmdstan/stan/lib/stan_math/stan/math/prim/fun/pow.hpp:64:36), nullptr, nullptr>' requested here 64 | return apply_scalar_binary(a, b, [](const auto& c, const auto& d) { | ^ pow.hpp:6351:21: note: in instantiation of function template specialization 'stan::math::pow>, std::complex, nullptr, nullptr>' requested here 6351 | stan::math::pow(d_complex_array, p_complex), | ^ pow.hpp:12239:12: note: in instantiation of function template specialization 'pow_model_namespace::pow_model::log_prob_impl, -1, 1>, Eigen::Matrix, nullptr, nullptr, nullptr>' requested here 12239 | return log_prob_impl(params_r, params_i, pstream); | ^ /home/jenkins/cmdstan/stan/src/stan/model/model_base_crtp.hpp:98:50: note: in instantiation of function template specialization 'pow_model_namespace::pow_model::log_prob>' requested here 98 | return static_cast(this)->template log_prob(theta, | ^ pow.hpp:991:3: note: in instantiation of member function 'stan::model::model_base_crtp::log_prob' requested here 991 | ~pow_model() {} | ^ 3 errors generated. ```

Unfortunately it doesn't look like adding const & to all our Ts fixes it

WardBrian commented 1 month ago

(note: that failure does not mention std::complex)

SteveBronder commented 1 month ago

Oh that's very interesting. Yes in that case I think just adding stan::math:: to pow calls in that test makes sense. We do that for the compiler generated code anyway