rstan
rstan copied to clipboard
Not compiling with clang19
Summary:
Models do not compile with clang19. @SteveBronder or @WardBrian do you know what this means?
Description:
From https://www.stats.ox.ac.uk/pub/bdr/clang19/AovBay.log , which like rstanarm depends on rstan, StanHeaders, etc.
In file included from stanExports_onewaymodel.cc:5:
In file included from ./stanExports_onewaymodel.h:25:
In file included from /data/gannet/ripley/R/test-clang/StanHeaders/include/src/stan/model/model_header.hpp:11:
/data/gannet/ripley/R/test-clang/StanHeaders/include/src/stan/model/model_base_crtp.hpp:140:50: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
140 | return static_cast<const M*>(this)->template write_array(
| ^
/data/gannet/ripley/R/test-clang/StanHeaders/include/src/stan/model/model_base_crtp.hpp:209:50: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw]
209 | return static_cast<const M*>(this)->template write_array(
| ^
Reproducible Steps:
Try to compile a model with clang19
Current Output:
None
Expected Output:
A compiled stanmodel object
RStan Version:
2.31.x
R Version:
4.4.x
Operating System:
Linux
From the error message, it looks like Clang 19 wants the empty template args <>, so it would look like this: (this)->template<> write_array(....
Clang19 isn’t actually released yet, correct?
I believe Bob is correct: https://github.com/llvm/llvm-project/pull/80801
Just in case it might help with CI - the RHub project has a variety of docker containers with setups including clang19
OK. Does the code need to test for clang version 19 or later or would making those lines be like Bob says be fine for other compilers too?
When we open a PR to change model base our CI should tell us whether or not it’s a problem on older clang and GCC
We should just be able to update. The syntax with the explicit <> should work on earlier compilers. But as @WardBrian says, the proof is in the CI.
Ah, upstream resolved this in https://github.com/stan-dev/stan/pull/3228 (part of 2.34) by removing the template keyword in this case. I think adding the <> is equivalent, but removing the keyword seemed more direct