Logic behind sizeof operator [duplicate]

The compiler knows the size of all types, it has to or it would not be able to generate code correctly. This information is used by the sizeof operator.

Also note that sizeof is not some function being called at runtime, it’s an operator that is fully evaluated during compilation.

Leave a Comment