Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation failures under LLVM 19 #3106

Closed
WardBrian opened this issue Sep 23, 2024 · 11 comments · Fixed by #3110
Closed

Compilation failures under LLVM 19 #3106

WardBrian opened this issue Sep 23, 2024 · 11 comments · Fixed by #3110

Comments

@WardBrian
Copy link
Member

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<stan::math::var_value<double, void>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote<int, stan::math::var_value<double>>' requested here

 1116 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>, $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<stan::math::var_value<double, void>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote<double, stan::math::var_value<double>>' requested here

 1116 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>, $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<stan::math::var_value<double, void>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote<stan::math::var_value<double>, int>' requested here

 1110 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>, _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<stan::math::var_value<double, void>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote<stan::math::var_value<double>, double>' requested here

 1110 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>, _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<stan::math::var_value<double, void>>::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<double>, stan::math::var_value<double>>' requested here

 1103 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>, _Up = stan::math::var_value<double>]

  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<stan::math::fvar<double>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote<int, stan::math::fvar<double>>' requested here

 1116 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>, $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<stan::math::fvar<double>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote<double, stan::math::fvar<double>>' requested here

 1116 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>, $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<stan::math::fvar<double>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote<stan::math::fvar<double>, int>' requested here

 1110 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>, _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<stan::math::fvar<double>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote<stan::math::fvar<double>, double>' requested here

 1110 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>, _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<stan::math::fvar<double>>::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<double>, stan::math::fvar<double>>' requested here

 1103 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>, _Up = stan::math::fvar<double>]

  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<stan::math::fvar<stan::math::fvar<double>>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote<stan::math::fvar<stan::math::fvar<double>>, int>' requested here

 1110 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<stan::math::fvar<double>>, _Up = int, $2 = (no value)]

  163 |   auto a2 = pow(std::complex<T>(1.0), 1);

      |             ^

test/unit/math/mix/fun_16_test.cpp:179:3: note: in instantiation of function template specialization 'expect_arith_instantiate<stan::math::fvar<stan::math::fvar<double>>>' requested here

  179 |   expect_arith_instantiate<fvar<fvar<double>>>();

      |   ^

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<stan::math::fvar<stan::math::fvar<double>>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote<stan::math::fvar<stan::math::fvar<double>>, double>' requested here

 1110 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<stan::math::fvar<double>>, _Up = double, $2 = (no value)]

  164 |   auto b2 = pow(std::complex<T>(1.0), 1.0);

      |             ^

test/unit/math/mix/fun_16_test.cpp:179:3: note: in instantiation of function template specialization 'expect_arith_instantiate<stan::math::fvar<stan::math::fvar<double>>>' requested here

  179 |   expect_arith_instantiate<fvar<fvar<double>>>();

      |   ^

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<stan::math::fvar<stan::math::fvar<double>>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote<int, stan::math::fvar<stan::math::fvar<double>>>' requested here

 1116 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<stan::math::fvar<double>>, $2 = (no value)]

  165 |   auto c2 = pow(1, std::complex<T>(1.0));

      |             ^

test/unit/math/mix/fun_16_test.cpp:179:3: note: in instantiation of function template specialization 'expect_arith_instantiate<stan::math::fvar<stan::math::fvar<double>>>' requested here

  179 |   expect_arith_instantiate<fvar<fvar<double>>>();

      |   ^

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<stan::math::fvar<stan::math::fvar<double>>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote<double, stan::math::fvar<stan::math::fvar<double>>>' requested here

 1116 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<stan::math::fvar<double>>, $2 = (no value)]

  166 |   auto d2 = pow(1.0, std::complex<T>(1.0));

      |             ^

test/unit/math/mix/fun_16_test.cpp:179:3: note: in instantiation of function template specialization 'expect_arith_instantiate<stan::math::fvar<stan::math::fvar<double>>>' requested here

  179 |   expect_arith_instantiate<fvar<fvar<double>>>();

      |   ^

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<stan::math::fvar<stan::math::fvar<double>>>::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<stan::math::fvar<double>>, stan::math::fvar<stan::math::fvar<double>>>' requested here

 1103 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<stan::math::fvar<double>>, _Up = stan::math::fvar<stan::math::fvar<double>>]

  167 |   auto e2 = pow(std::complex<T>(1.0), std::complex<T>(1.0));

      |             ^

test/unit/math/mix/fun_16_test.cpp:179:3: note: in instantiation of function template specialization 'expect_arith_instantiate<stan::math::fvar<stan::math::fvar<double>>>' requested here

  179 |   expect_arith_instantiate<fvar<fvar<double>>>();

      |   ^

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<stan::math::fvar<stan::math::var_value<double, void>>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote<stan::math::fvar<stan::math::var_value<double>>, int>' requested here

 1110 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<stan::math::var_value<double>>, _Up = int, $2 = (no value)]

  163 |   auto a2 = pow(std::complex<T>(1.0), 1);

      |             ^

test/unit/math/mix/fun_16_test.cpp:180:3: note: in instantiation of function template specialization 'expect_arith_instantiate<stan::math::fvar<stan::math::var_value<double>>>' requested here

  180 |   expect_arith_instantiate<fvar<var>>();

      |   ^

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<stan::math::fvar<stan::math::var_value<double, void>>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1110:47: note: in instantiation of template class 'std::__promote<stan::math::fvar<stan::math::var_value<double>>, double>' requested here

 1110 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<stan::math::var_value<double>>, _Up = double, $2 = (no value)]

  164 |   auto b2 = pow(std::complex<T>(1.0), 1.0);

      |             ^

test/unit/math/mix/fun_16_test.cpp:180:3: note: in instantiation of function template specialization 'expect_arith_instantiate<stan::math::fvar<stan::math::var_value<double>>>' requested here

  180 |   expect_arith_instantiate<fvar<var>>();

      |   ^

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<stan::math::fvar<stan::math::var_value<double, void>>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote<int, stan::math::fvar<stan::math::var_value<double>>>' requested here

 1116 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<stan::math::var_value<double>>, $2 = (no value)]

  165 |   auto c2 = pow(1, std::complex<T>(1.0));

      |             ^

test/unit/math/mix/fun_16_test.cpp:180:3: note: in instantiation of function template specialization 'expect_arith_instantiate<stan::math::fvar<stan::math::var_value<double>>>' requested here

  180 |   expect_arith_instantiate<fvar<var>>();

      |   ^

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<stan::math::fvar<stan::math::var_value<double, void>>>::value'

   32 |   static_assert((is_arithmetic<_Args>::value && ...));

      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/local/include/c++/v1/complex:1116:47: note: in instantiation of template class 'std::__promote<double, stan::math::fvar<stan::math::var_value<double>>>' requested here

 1116 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<stan::math::var_value<double>>, $2 = (no value)]

  166 |   auto d2 = pow(1.0, std::complex<T>(1.0));

      |             ^

test/unit/math/mix/fun_16_test.cpp:180:3: note: in instantiation of function template specialization 'expect_arith_instantiate<stan::math::fvar<stan::math::var_value<double>>>' requested here

  180 |   expect_arith_instantiate<fvar<var>>();

      |   ^

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
Copy link
Member Author

Looks like this static assert was introduced by llvm/llvm-project#81379

@WardBrian
Copy link
Member Author

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

@WardBrian
Copy link
Member Author

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

@SteveBronder
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Member Author

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

@SteveBronder
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Member Author

@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<stan::math::var_value<double, void>>::value'
   32 |   static_assert((is_arithmetic<_Args>::value && ...));
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/v1/complex:1103:47: note: in instantiation of template class 'std::__promote<double, stan::math::var_value<double>>' requested here
 1103 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::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<double>]
   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<std::complex<double>> &, const std::complex<stan::math::var> &)::(anonymous class)::operator()<std::complex<double>, std::complex<stan::math::var>>' requested here
  290 |   using T_return = std::decay_t<decltype(f(x[0], y))>;
      |                                          ^
/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::vector<std::complex<double>>, std::complex<stan::math::var>, (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::vector<std::complex<double>>, std::complex<stan::math::var>, 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<false, false, Eigen::Matrix<stan::math::var_value<double>, -1, 1>, Eigen::Matrix<int, -1, 1>, nullptr, nullptr, nullptr>' requested here
 12239 |     return log_prob_impl<propto__, jacobian__>(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<false, false, stan::math::var_value<double>>' requested here
   98 |     return static_cast<const M*>(this)->template log_prob<false, false>(theta,
      |                                                  ^
pow.hpp:991:3: note: in instantiation of member function 'stan::model::model_base_crtp<pow_model_namespace::pow_model>::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
Copy link
Member Author

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

@SteveBronder
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants