Quick A: a constexpr function does not imply it will be evaluated at compile time.
Recently on SO:
Your constexpr function requires way too much computation to do in a compiler, that's why the compiler chooses to delay it to runtime execution.
You can change this line:static const auto c_x = c_fun(40);
to:constexpr auto c_x = c_fun(40);
to see compiler's output. On clang, it tells me:
note: constexpr evaluation hit maximum step limit;
c_x is indeed a compile-time constant, but the compiler can't compute it due to implementation limitation. Note that your function has exponential complexity.
Everything will be fine if you change 40 to some reasonable number, like 10:constexpr auto c_x = c_fun(10);