How sizeof(array) works at runtime?

sizeof is always computed at compile time in C89. Since C99 and variable length arrays, it is computed at run time when a variable length array is part of the expression in the sizeof operand.

Same for the evaluation of the sizeof operand: it is not evaluated in C89 but in C99 if the operand is of variable length array type it is evaluated. For example:

int n = 5;
sizeof (int [n++]); 

// n is now 6

Leave a Comment