Until (and not including)Prior to C++14, the body of a constexpr function must consist solely of a return statement: it cannot have any other statements inside it. This works in C++11 :
constexpr int func (int x) { return x < 0 ? -x : x; } In C++14 and up, what you wrote is legal, as are most other statements.