sizeof is evaluated at compile time: the compiler evaluates the type of expression following the sizeof operator. This is done once and for all by the compiler, so the sentence is "without actually evaluating this expression at runtime."
The compiler calculates the type, then it can infer the size of the expression from this type, and then, even during compilation, the whole sizeof expression is replaced by the calculated size. Thus, the expression itself is not part of the executable code. This means that the sentence "sizeof discards the expression and returns only the size of its result."
source share