On Jan 24, 2009, at 12:43 PM, Eli Friedman wrote:

> On Sat, Jan 24, 2009 at 12:17 PM, Chris Lattner <[email protected]>  
> wrote:
>> +  // alignof decl is always ok.
>> +  if (isa<DeclRefExpr>(E))
>> +    return false;
>
> That looks wrong... what about something like the following?
>
> extern struct x a;
> int b = __alignof(a);
>
> Wait, actually, it appears that gcc accepts this?!
>
> Conceptually, it seems like a better fix for PR3386 would be adding
> something like "if (!isSizeof && exprType->isIncompleteArrayType())
> exprType = exprType->getAsArrayType()->getElementType();" at the
> beginning of CheckSizeOfAlignOfOperand.

unfortunately, that's not what GCC does.  GCC allows alignof on any  
decl (except bitfield), and takes the alignment of the decl.  This  
means that if you use attribute(align) it should affect alignof.

I'm working on the ExprConstant code to better handle alignof.

-Chris
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to