-
-
Notifications
You must be signed in to change notification settings - Fork 380
Closed
stan-dev/stanc3
#1557Description
Of little significance/priority, as I've just realized because fmin
and fmax
exist - but still a bug IMO, as the manual states "Function names used in the Stan standard library may be overloaded by user-defined functions. Exceptions to this are the reduce_sum family of functions and ODE integrators, which cannot be overloaded.".
Also, that should probably more accurately read "Exceptions to this are higher order functions, such as [...]" and could/would then also include e.g. the Newton solver.
Working MWE:
functions {
real mymin(real x, real y) {
return x < y ? x : y;
}
}
transformed data {
real m = mymin(1., 2.);
}
Failing MWE:
functions {
real min(real x, real y) {
return x < y ? x : y;
}
}
transformed data {
real m = min(1., 2.);
}
Error:
┌ Error: Compilation failed!
│ Command: setenv(`make /home/niko/github/nsiccha/mwe/BridgeStan6/crash_model.so`; dir="/home/niko/.bridgestan/bridgestan-2.7.0")
│ stdout:
│ --- Translating Stan model to C++ code ---
│ ./bin/stanc --o=/home/niko/github/nsiccha/mwe/BridgeStan6/crash.hpp /home/niko/github/nsiccha/mwe/BridgeStan6/crash.stan
│
│ --- Compiling C++ code ---
│ g++ -std=c++17 -pthread -D_REENTRANT -Wno-sign-compare -Wno-ignored-attributes -Wno-class-memaccess -I ./stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I ./stan/src -I ./stan/lib/rapidjson_1.1.0/ -I ./stan/lib/stan_math/ -I ./stan/lib/stan_math/lib/eigen_3.4.0 -I ./stan/lib/stan_math/lib/boost_1.87.0 -I ./stan/lib/stan_math/lib/sundials_6.1.1/include -I ./stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -DBOOST_DISABLE_ASSERTS -DBRIDGESTAN_EXPORT -DSTAN_OVERRIDE_EIGEN_ASSERT -c -x c++ -o /home/niko/github/nsiccha/mwe/BridgeStan6/crash.o /home/niko/github/nsiccha/mwe/BridgeStan6/crash.hpp
│ rm /home/niko/github/nsiccha/mwe/BridgeStan6/crash.hpp
│
│ stderr: /home/niko/github/nsiccha/mwe/BridgeStan6/crash.hpp: In constructor ‘crash_model_namespace::crash_model::crash_model(stan::io::var_context&, unsigned int, std::ostream*)’:
│ /home/niko/github/nsiccha/mwe/BridgeStan6/crash.hpp:74:14: error: call of overloaded ‘max(double, double, std::ostream*&)’ is ambiguous
│ 74 | m = max(1., 2., pstream__);
│ | ~~~^~~~~~~~~~~~~~~~~~~
│ /home/niko/github/nsiccha/mwe/BridgeStan6/crash.hpp:30:1: note: candidate: ‘stan::return_type_t<T1, T2> crash_model_namespace::max(const T0__&, const T1__&, std::ostream*) [with T0__ = double; T1__ = double; stan::require_all_t<stan::math::disjunction<stan::is_autodiff<T0__>, std::is_floating_point<typename std::decay<_Tp>::type> >, stan::math::disjunction<stan::is_autodiff<T1__>, std::is_floating_point<typename std::decay<_Tp2>::type> > >* <anonymous> = 0; stan::return_type_t<T1, T2> = double; std::ostream = std::basic_ostream<char>]’
│ 30 | max(const T0__& x, const T1__& y, std::ostream* pstream__) {
│ | ^~~
│ In file included from /usr/include/c++/11/bits/char_traits.h:39,
│ from /usr/include/c++/11/ios:40,
│ from /usr/include/c++/11/istream:38,
│ from /usr/include/c++/11/sstream:38,
│ from ./stan/src/stan/io/var_context.hpp:4,
│ from ./stan/src/stan/model/model_base.hpp:7,
│ from ./stan/src/stan/model/model_header.hpp:4,
│ from /home/niko/github/nsiccha/mwe/BridgeStan6/crash.hpp:2:
│ /usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: ‘constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = double; _Compare = std::basic_ostream<char>*]’
│ 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
│ | ^~~
│ make: *** [Makefile:77: /home/niko/github/nsiccha/mwe/BridgeStan6/crash.o] Error 1
└ @ Main ~/github/nsiccha/mwe/BridgeStan6/crash.jl:9
Metadata
Metadata
Assignees
Labels
No labels