Skip to content

Compilation failure with Clang 17 and check_symmetric #2989

@WardBrian

Description

@WardBrian

Description

Caught in https://jenkins.flatironinstitute.org/blue/organizations/jenkins/Stan%2FBleedingEdgeCompilersMonthly/detail/BleedingEdgeCompilersMonthly/160/pipeline

The error occurs when building the eigendecompose_sym test models from stanc3 (and eigenvalues_sym and eigenvectors_sym):

--- Compiling C++ code ---
clang++ -nostdinc++ -nostdlib++ -I/usr/local/include/c++/v1 -march=core2 -std=c++1y -D_REENTRANT -Wno-sign-compare -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2020.3/include    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.81.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -nostdinc++ -nodefaultlibs -I/usr/local/include/c++/v1     -DBOOST_DISABLE_ASSERTS          -c  -x c++ -o ../../stanc3/test/integration/good/function-signatures/math/matrix/eigendecompose_sym.o ../../stanc3/test/integration/good/function-signatures/math/matrix/eigendecompose_sym.hpp

In file included from ../../stanc3/test/integration/good/function-signatures/math/matrix/eigendecompose_sym.hpp:2:
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:19:
In file included from stan/lib/stan_math/stan/math/rev.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:53:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:9:
In file included from stan/lib/stan_math/stan/math/prim/err.hpp:13:
In file included from stan/lib/stan_math/stan/math/prim/err/check_corr_matrix.hpp:9:
In file included from stan/lib/stan_math/stan/math/prim/err/check_pos_definite.hpp:8:
stan/lib/stan_math/stan/math/prim/err/check_symmetric.hpp:44:13: error: call to function 'fabs' that is neither visible in the template definition nor found by argument-dependent lookup
   44 |       if (!(fabs(value_of(y_ref(m, n)) - value_of(y_ref(n, m)))
      |             ^
stan/lib/stan_math/stan/math/prim/fun/eigendecompose_sym.hpp:32:3: note: in instantiation of function template specialization 'stan::math::check_symmetric<Eigen::Matrix<std::complex<double>, -1, -1>, nullptr>' requested here
   32 |   check_symmetric("eigendecompose_sym", "m", m_eval);
      |   ^
../../stanc3/test/integration/good/function-signatures/math/matrix/eigendecompose_sym.hpp:182:21: note: in instantiation of function template specialization 'stan::math::eigendecompose_sym<Eigen::Map<Eigen::Matrix<std::complex<double>, -1, -1>>, nullptr, nullptr>' requested here
  182 |         stan::math::eigendecompose_sym(d_cmatrix),
      |                     ^
stan/lib/stan_math/stan/math/prim/fun/fabs.hpp:19:13: note: 'fabs' should be declared prior to the call site
   19 | inline auto fabs(T x) {
      |             ^

In file included from ../../stanc3/test/integration/good/function-signatures/math/matrix/eigendecompose_sym.hpp:2:
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:19:
In file included from stan/lib/stan_math/stan/math/rev.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:53:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:9:
In file included from stan/lib/stan_math/stan/math/prim/err.hpp:13:
In file included from stan/lib/stan_math/stan/math/prim/err/check_corr_matrix.hpp:9:
In file included from stan/lib/stan_math/stan/math/prim/err/check_pos_definite.hpp:8:
stan/lib/stan_math/stan/math/prim/err/check_symmetric.hpp:44:13: error: call to function 'fabs' that is neither visible in the template definition nor found by argument-dependent lookup
   44 |       if (!(fabs(value_of(y_ref(m, n)) - value_of(y_ref(n, m)))
      |             ^
stan/lib/stan_math/stan/math/prim/fun/eigendecompose_sym.hpp:32:3: note: in instantiation of function template specialization 'stan::math::check_symmetric<Eigen::Matrix<std::complex<stan::math::var>, -1, -1>, nullptr>' requested here
   32 |   check_symmetric("eigendecompose_sym", "m", m_eval);
      |   ^
../../stanc3/test/integration/good/function-signatures/math/matrix/eigendecompose_sym.hpp:339:21: note: in instantiation of function template specialization 'stan::math::eigendecompose_sym<Eigen::Matrix<std::complex<stan::math::var>, -1, -1>, nullptr, nullptr>' requested here
  339 |         stan::math::eigendecompose_sym(p_cmatrix),
      |                     ^
../../stanc3/test/integration/good/function-signatures/math/matrix/eigendecompose_sym.hpp:751:12: note: in instantiation of function template specialization 'eigendecompose_sym_model_namespace::eigendecompose_sym_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
  751 |     return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);
      |            ^
stan/src/stan/model/model_base_crtp.hpp:98:50: note: in instantiation of function template specialization 'eigendecompose_sym_model_namespace::eigendecompose_sym_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,
      |                                                  ^
../../stanc3/test/integration/good/function-signatures/math/matrix/eigendecompose_sym.hpp:59:3: note: in instantiation of member function 'stan::model::model_base_crtp<eigendecompose_sym_model_namespace::eigendecompose_sym_model>::log_prob' requested here
   59 |   ~eigendecompose_sym_model() {}
      |   ^
stan/lib/stan_math/stan/math/prim/fun/fabs.hpp:19:13: note: 'fabs' should be declared prior to the call site
   19 | inline auto fabs(T x) {
      |             ^
make: [make/program:61: ../../stanc3/test/integration/good/function-signatures/math/matrix/eigendecompose_sym.o] Error 1 (ignored)

This seems similar to #2892, but I am unable to recreate with llvm16 so it might be a new problem in 17 also related to ADL. @andrjohns - are you able to use llvm17 and take a look at this?

Expected Output

Current Version:

v4.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions