Open ebuhle opened 9 months ago
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)
Will do
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