C++14 has rules for what you can and can\'t do in a constexpr
function. Some of them (no asm
, no static variables) seem pretty reasonable. But the Stan
constexpr
is expected to be evaluated by the front-end of the compiler in some pseudo-interpreted mode or on the abstract syntax tree built in a single pass before any executable code is generated. We know that goto
may jump to some part at the end of the function which was not evaluated yet. Hence properly connecting calling and executing goto
would force building AST in several passes and jumping out of order between nodes in a tree is still a messy operation that could break some state. So such a construction is not worth the trouble.