K&R c 2nd edition(section 2.3) mentions
A constant expression is an expression that involves only constants. Such expressions may be evaluated at during compilation rather than run-time, and accordingly may be used in any place that a constant can occur
however, I have several doubts regarding it:
Will this expression be considered as constant expression?
const int x=5; const int y=6; int z=x+y;
i.e using
const
keyword is considered constant expression or not?Is there any technique by which we can check whether an expression was evaluated during compilation or during run-time?
Are there any cases where compile time evaluation produces different result than run-time evaluation?
Should I even care about it? (maybe I use it to optimize my programs)