[cfe-dev] sizeof(sizeof(...))

Ted Kremenek kremenek at apple.com
Fri Dec 14 14:40:03 PST 2007

On Dec 14, 2007, at 2:21 PM, Bill Wendling wrote:

> Well, the standard says to "integer" type, so probably not unsigned.
> But that's my understanding of it. Though I don't believe that sizeof
> should be evaluating the expression...

There are occasions when sizeof(type) actually does evaluate an  
expression in the case of VLA types.  This is what prompted this email  
(I'm trying to piece together all the contingencies).  In clang, the  
issue is that when the argument type of SizeOfAlignOfTypeExpr is of  
type VariableArrayType the size expression of the VLA type must be  
evaluated (within the sizeof) in order to determine the size of the  
type.  I believe this excludes typedefs, since the size expression  
will be evaluated at the typedef location.  There may be other corner  
cases I'm not seeing yet with sizeof and VLAs.

More information about the cfe-dev mailing list