There are two separate issues with your query: constness and constant arithmetic expressions. The constness issue comes up because you used the const modifier. Your question involves both.
Constant Arithmetic (or textual) Expressions
The compiler may precompute (evaluate) expressions that have no variables before generating any intermediate code or final assembly code. The compiler may implement an assignment of a constant expression in any method, usually for optimization, as log as final result of the generated code is equal to the expression.
For example, some processors can load a value into a register by using shifts and adds faster than it can by loading a value from a location in the executable. The ARM processor is one of these. Thus the value 29 would be more efficient to load using shifts than to load from a location.
A variable definition does not have to be const in order for the compiler to evaluate and "precompute" a constant arithmetic expression.
The const Modifier
Using const in a variable declaration or definition informs the compiler that the variable will not be modified before the end of the current scope. Any modifications to the variable, from assignments to use as parameters to functions, shall generate error messages to the user.
The 'const' variable definition need not consist only of constant arithmetic or textual expressions. For example:
void function (const std::string text)
{
const std::string::size_type extra_length(text.length() + 5);
std::cout << "Extra text length: " << extra_length << "\n";
return;
}
In the above example, the variable extra_length cannot be "precomputed" since it depends on the function parameter, yet it is declared as const.
Summary
Evaluation of constant arithmetic or textual expressions are a separate concept from usage of the const modifier. Most compilers will evaluate and simplify constant arithmetic expressions before applying their values to the code generator. The value of the expression may not appear in the generated code since the compiler is allowed to generate code that computes the value as long as the computed value is equal to the value of the arithmetic expression. This may be performed as a technique for generating optimal executable code.