Compilation error - how to debug it?

Hello Stan experts,

I got my first situation now where the initial syntax check or so that stan is doing passes, but the compilation fails. And I don’t really understand why or how I can start to debug this - I tried to change the code for an hour and it still fails. I cannot reproduce the compilation error when having the single function in a separate stan file.

The problem comes down to a block of code like this:

  matrix fun(matrix time) {
    matrix[rows(time), cols(time)] result;
    real val;
    val = time[1, 2];
    return result;

(note that this is simplified but it fails like this) It starts compiling but after few seconds gives a huge error message, that ends with:

stan/src/stan/model/indexing/rvalue.hpp:55:10: note:   template argument deduction/substitution failed:
/tmp/RtmpiGD5kC/model-4fe3695a40a9.hpp:436:17: note:   candidate expects 2 arguments, 4 provided
  436 |     val = rvalue(time, "time", index_uni(1), index_uni(2));
      |           ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [make/program:58: /tmp/RtmpiGD5kC/model-4fe3695a40a9] Fehler 1
Fehler: An error occured during compilation! See the message above for more information.
  • Operating System: Ubuntu 20.04.3 LTS
  • CmdStan Version: 2.28.2 via cmdstanr_0.4.0
  • Compiler/Toolkit: g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

Thanks in advance for any pointers!!

Can this be a bug that I should better report on the github repo?

Yeah. Can you just report it on the cmdstanr repo and once we dig deeper we can move the issue elsewhere.


1 Like

Thanks @rok_cesnovar - filed at