-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
"call of overloaded ‘sqrt(int)’ is ambiguous" using g++ 7.2.0 #2478
Comments
It is a Stan (Math) issue and has already had several issues filed about it over the years, such as stan-dev/math#712 |
I spun up a docker image and tested it with Ubuntu with g++ 7.2.0. It works fine with CmdStan. I'm trying to reproduce the error in RStan, but having trouble installing RStan under that configuration. |
if you think I could be of any help (I am a really entry-level STAN user) let me know! |
@zottelef, thank you! There is something you could try to help us figure this out. Can you:
What I'm trying to tease apart is whether this is a configuration problem in RStan or CmdStan / Stan. |
@bgoodri, this is the result I have from building from CmdStan (tagged version v2.17.1):
No compiler error.
|
@zottelef, please let me know if you run into any trouble getting that up and running. It took me less than 30 minutes, but I know CmdStan inside and out. |
Thanks. Yikes. How in the world would R be messing things up? Is it something in the Makevars?
|
|
The solution's the same here. Write our own sqrt() and make
sure we call that.
- Bob
… On Feb 28, 2018, at 2:16 PM, bgoodri ***@***.***> wrote:
***@***.***:/opt/cmdstan$ make /tmp/sqrt
--- Translating Stan model to C++ code ---
bin/stanc /tmp/sqrt.stan --o=/tmp/sqrt.hpp
Model name=sqrt_model
Input file=/tmp/sqrt.stan
Output file=/tmp/sqrt.hpp
--- Linking C++ model ---
g++-7 -Wall -I . -isystem stan/lib/stan_math/lib/eigen_3.3.3 -isystem stan/lib/stan_math/lib/boost_1.64.0 -isystem stan/lib/stan_math/lib/cvodes_2.9.0/include -std=c++1y -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I src -I stan/src -isystem stan/lib/stan_math/ -DEIGEN_NO_DEBUG -DFUSION_MAX_VECTOR_SIZE=12 -DNO_FPRINTF_OUTPUT -pipe -lpthread -O3 -o /tmp/sqrt src/cmdstan/main.cpp -include /tmp/sqrt.hpp stan/lib/stan_math/lib/cvodes_2.9.0/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/cvodes_2.9.0/lib/libsundials_cvodes.a
In file included from <command-line>:0:0:
/tmp/sqrt.hpp: In member function ‘void sqrt_model_namespace::sqrt_model::ctor_body(stan::io::var_context&, unsigned int, std::ostream*)’:
/tmp/sqrt.hpp:125:240: error: call of overloaded ‘sqrt(int)’ is ambiguous
:model::rvalue(qr_Q(x), stan::model::cons_list(stan::model::index_omni(), stan::model::cons_list(stan::model::index_min_max(1, K), stan::model::nil_index_list())), "qr_Q(x)"),sqrt((N - 1))));
^
In file included from /usr/include/features.h:419:0,
from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
from /usr/include/stdint.h:26,
from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9,
from stan/lib/stan_math/stan/math/memory/stack_alloc.hpp:6,
from stan/lib/stan_math/stan/math/rev/core/autodiffstackstorage.hpp:4,
from stan/lib/stan_math/stan/math/rev/core.hpp:4,
from stan/lib/stan_math/stan/math/rev/mat.hpp:4,
from stan/lib/stan_math/stan/math.hpp:4,
from stan/src/stan/model/model_header.hpp:4,
from /tmp/sqrt.hpp:3,
from <command-line>:0:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:149:1: note: candidate: double sqrt(double)
__MATHCALL (sqrt,, (_Mdouble_ __x));
^
In file included from stan/lib/stan_math/lib/boost_1.64.0/boost/config/no_tr1/cmath.hpp:21:0,
from stan/lib/stan_math/lib/boost_1.64.0/boost/math/tools/config.hpp:19,
from stan/lib/stan_math/stan/math/rev/core/var.hpp:7,
from stan/lib/stan_math/stan/math/rev/core/gevv_vvv_vari.hpp:5,
from stan/lib/stan_math/stan/math/rev/core.hpp:12,
from stan/lib/stan_math/stan/math/rev/mat.hpp:4,
from stan/lib/stan_math/stan/math.hpp:4,
from stan/src/stan/model/model_header.hpp:4,
from /tmp/sqrt.hpp:3,
from <command-line>:0:
/usr/include/c++/7/cmath:463:3: note: candidate: constexpr float std::sqrt(float)
sqrt(float __x)
^~~~
/usr/include/c++/7/cmath:467:3: note: candidate: constexpr long double std::sqrt(long double)
sqrt(long double __x)
^~~~
/usr/include/c++/7/cmath:475:5: note: candidate: constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::sqrt(_Tp) [with _Tp = int; typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type = double]
sqrt(_Tp __x)
^~~~
In file included from stan/lib/stan_math/stan/math/rev/scal/fun/pow.hpp:5:0,
from stan/lib/stan_math/stan/math/rev/scal/fun/inc_beta.hpp:7,
from stan/lib/stan_math/stan/math/rev/scal/fun/grad_inc_beta.hpp:12,
from stan/lib/stan_math/stan/math/rev/scal.hpp:50,
from stan/lib/stan_math/stan/math/rev/arr.hpp:9,
from stan/lib/stan_math/stan/math/rev/mat.hpp:13,
from stan/lib/stan_math/stan/math.hpp:4,
from stan/src/stan/model/model_header.hpp:4,
from /tmp/sqrt.hpp:3,
from <command-line>:0:
stan/lib/stan_math/stan/math/rev/scal/fun/sqrt.hpp:50:16: note: candidate: stan::math::var stan::math::sqrt(const stan::math::var&)
inline var sqrt(const var& a) {
^~~~
In file included from stan/lib/stan_math/stan/math/prim/mat.hpp:209:0,
from stan/lib/stan_math/stan/math/rev/mat.hpp:12,
from stan/lib/stan_math/stan/math.hpp:4,
from stan/src/stan/model/model_header.hpp:4,
from /tmp/sqrt.hpp:3,
from <command-line>:0:
stan/lib/stan_math/stan/math/prim/mat/fun/sqrt.hpp:32:5: note: candidate: typename stan::math::apply_scalar_unary<stan::math::sqrt_fun, T>::return_t stan::math::sqrt(const T&) [with T = int; typename stan::math::apply_scalar_unary<stan::math::sqrt_fun, T>::return_t = double]
sqrt(const T& x) {
^~~~
make: *** [make/models:12: /tmp/sqrt] Error 1
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@bgoodri, is that compiler installed on the linux box? If so, I think we can run a test in Stan (compile all models) with Jenkins that will test that things are C++ compilable with that compiler. |
(I can't reproduce the failure with g++ 7.2.0.) |
Yes
…On Wed, Feb 28, 2018 at 4:02 PM, Daniel Lee ***@***.***> wrote:
@bgoodri <https://github.com/bgoodri>, is that compiler installed on the
linux box?
If so, I think we can run a test in Stan (compile all models) with Jenkins
that will test that things are C++ compilable with that compiler.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2478 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADOrqiVqlorn9SiB9foEJPc_h1wxV-ydks5tZb7QgaJpZM4SWwLs>
.
|
@bgoodri, mind doing me a favor and seeing if this test fails in Stan? (after setting
We've written out a lot of Stan programs that we assume to be compilable by the C++ compiler and the two tests in there make sure they're parsed properly and that they compile. If that catches when it doesn't work, we can put that into a Jenkins job and make sure we are able to keep compiling with changes to the code base. |
@syclik : sorry for the late answer. I did not notice the advances in the topic. Really sorry about that.
|
Thank you! |
OK, this is the one I meant to reopen, as the problem's in this repo. |
Summary: Description: Reproducible Steps:
Current Output:
and
Expected Output: Current Version: |
This very likely isnt an issue anymore and any chance of ambiguity in the future will be the handled by stan-dev/math#1692 anyways. |
Summary:
A valid Stan program is failing to C++ compile on Linux using g++ 7.2.0.
This is failing from RStan, so we need to see if it's a Stan problem or an RStan problem.
(Originally reported by @zottelef on Discourse: http://discourse.mc-stan.org/t/qr-reparametrization-error/3426/9)
Description:
This program generates C++ code and then fails to compile.
Reproducible Steps:
We need to determine if this is an RStan or a Stan problem. This error was reported using:
Current Output:
The relevant part of the compiler error is:
Here's the rest of the reported compiler error:
Expected Output:
No error.
Current Version:
v2.17.1
The text was updated successfully, but these errors were encountered: