
The constexpr is not evaluated in compile-time as seen in the assembly(CALL instruction), why?
(Using most recent gcc that comes with codeblocks (g++ 4.7.1) with -std=c++11)

The constexpr is not evaluated in compile-time as seen in the assembly(CALL instruction), why?
(Using most recent gcc that comes with codeblocks (g++ 4.7.1) with -std=c++11)
Your getOdd() isn't constexpr and the compiler is certainly not required to propagate constant expressions through non-constexpr functions. Also, did you compile with optimization enabled? Without optimizations compilers tend to do no otimizations at all.
constexpr doesn't guarantee compile-time evaluation. It only guarantees that the constexpr, when fed compile-time constant inputs itself resolves to a compile-time constant.
In this case, the compiler chose not to evaluate getOdd(7), even though it could have. (Note, getOdd itself isn't constexpr even though isEven is.)
The compiler might choose to optimize and inline, for example, you increase your optimization level. But that has little to do with constexpr.
g++ -O3 will evaluate the expression at compile-time.
Note by the way that a simpler implementation of getOdd would be to return t | 1.