You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compilation fails with rstan 2.32.5 and StanHeaders 2.32.5 under R 4.3.x if the model code contains an expression of the form max(max(int, int), int), i.e. nested calls to max() with integer arguments.
Description:
After recently updating from rstan 2.32.2 and StanHeaders 2.26.28 to the current 2.32.5 versions of both packages in R 4.3.2, I was unable to compile some previously working Stan models. Through a lot of trial and error, removing code blocks until compilation succeeded and then adding them back until it failed again, I managed to isolate the issue to nested integer-max calls. If a model contains an expression like max(max(int, int), int), the compiler throws an error. If the inner max(int, int) is replaced by a constant integer or a previously defined int variable, or if the arguments to max() are real instead of int, compilation works.
A colleague and I have reproduced this in R 4.3.0 and 4.3.2 on two machines running different versions of Windows.
Reproducible Steps:
test1.stan<-"transformed data { int test = max(max(1, 1), 1);}"test1<-rstan::stan_model(model_code=test1.stan) # errortest2.stan<-"transformed data { int test = max(1, 1);}"test2<-rstan::stan_model(model_code=test2.stan) # no error
Current Output:
The first example produces the following compiler output followed by an error:
Thanks for reporting, this was a bug in our math library.
@bgoodri this is another really easy backport: replace return_type_t<T1, T2> with auto for the prim overload of max (and min, too, which has the same issue)
Summary:
Compilation fails with rstan 2.32.5 and StanHeaders 2.32.5 under R 4.3.x if the model code contains an expression of the form
max(max(int, int), int)
, i.e. nested calls tomax()
with integer arguments.Description:
After recently updating from rstan 2.32.2 and StanHeaders 2.26.28 to the current 2.32.5 versions of both packages in R 4.3.2, I was unable to compile some previously working Stan models. Through a lot of trial and error, removing code blocks until compilation succeeded and then adding them back until it failed again, I managed to isolate the issue to nested integer-max calls. If a model contains an expression like
max(max(int, int), int)
, the compiler throws an error. If the innermax(int, int)
is replaced by a constant integer or a previously definedint
variable, or if the arguments tomax()
arereal
instead ofint
, compilation works.A colleague and I have reproduced this in R 4.3.0 and 4.3.2 on two machines running different versions of Windows.
Reproducible Steps:
Current Output:
The first example produces the following compiler output followed by an error:
Expected Output:
Successful compilation producing a
stanmodel
object.RStan Version:
rstan 2.32.5 and StanHeaders 2.32.5
R Version:
R 4.3.0 or 4.3.2
Operating System:
Windows
The text was updated successfully, but these errors were encountered: