Trouble Updating CmdStan to 2.36: C++20 Compatibility Issues

Background: About a month ago I ran into some issues with a Stan model that I was running using the Rethinking package. I was advised to ensure that I had the latest version of cmdstan & cmdstanr, so I attempted to update these. (cmdstan 2.35 was still the latest version at that time, I believe.) The update process didn’t go smoothly; I got a long series of error/warning messages (quoted below) which generative AI told me is due to my computer using C++20 instead of C++17. Generative AI had me edit the make/local file with the line

CXXFLAGS += -std=c++17

and then rebuild cmdstan. This seemed to work.

Today: When I saw that cmdstan 2.36 was launched, I tried updating to that, and got the same errors/warnings. I tried to implement the same fix as before, adding the line to the make/local file to specify the C++17 standard, but this time it doesn’t seem to work.

The errors/warnings came too quickly for me to copy all of them, but what I did capture seems pretty repetitive; most of the warnings look like snippet 1. Snippet 2 only showed up at the end of the rebuild/install process.

Snippet 1:

In file included from stan/lib/stan_math/lib/tbb_2020.3/include/tbb/tbb_profiling.h:123,
from stan/lib/stan_math/lib/tbb_2020.3/include/tbb/task.h:36,
from stan/lib/stan_math/lib/tbb_2020.3/include/tbb/task_arena.h:23,
from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:18,
from src/cmdstan/arguments/arg_num_threads.hpp:5,
from src/cmdstan/command.hpp:8,
from src/cmdstan/main.cpp:1:
stan/lib/stan_math/lib/tbb_2020.3/include/tbb/atomic.h:422:24: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]
422 | constexpr atomic(const atomic& rhs): internal::atomic_impl(rhs) {}
| ^
stan/lib/stan_math/lib/tbb_2020.3/include/tbb/atomic.h:422:24: note: remove the ‘< >’
stan/lib/stan_math/lib/tbb_2020.3/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]
437 | constexpr atomic(const atomic& rhs):
| ^
stan/lib/stan_math/lib/tbb_2020.3/include/tbb/atomic.h:454:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’
454 | __TBB_DECL_ATOMIC(__TBB_LONG_LONG)
| ^~~~~~~~~~~~~~~~~

Snippet 2:

In file included from stan/lib/stan_math/stan/math/prim/prob/std_normal_ccdf_log.hpp:5,
from stan/lib/stan_math/stan/math/prim/prob.hpp:276,
from stan/lib/stan_math/stan/math/prim.hpp:18,
from stan/src/stan/io/dump.hpp:7,
from src/cmdstan/command_helper.hpp:10,
from src/cmdstan/command.hpp:13:
stan/lib/stan_math/stan/math/prim/prob/std_normal_lccdf.hpp: In function ‘stan::return_type_t stan::math::std_normal_lccdf(const T_y&)’:
stan/lib/stan_math/stan/math/prim/prob/std_normal_lccdf.hpp:52: note: ‘-Wmisleading-indentation’ is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
52 | } else if (y_dbl > 8.25) {
stan/lib/stan_math/stan/math/prim/prob/std_normal_lccdf.hpp:52: note: adding ‘-flarge-source-files’ will allow for more column-tracking support, at the expense of compilation time and memory

Any help in repairing my installation of cmdstan and/or resolving these issues would be greatly appreciated!

Requested additional information:

  • Operating System: Windows 11
  • CmdStan Version: 2.36.0
  • Compiler/Toolkit: GCC 13.3.0; GNU Make 4.4.1
  • RStudio Version: RStudio 2024.12.0

UPDATE: I’m still not fully sure why, but my laptop no longer seems to be running into this issue. My best guess is that a driver update fixed things. I’m not tech-savvy so that’s a very uneducated guess on my part! But I can’t think of any other explanation.

1 Like