[cfe-commits] r41613 - in /cfe/trunk: AST/Expr.cpp Sema/Sema.h Sema/SemaExpr.cpp include/clang/AST/Expr.h include/clang/AST/StmtVisitor.h include/clang/Basic/DiagnosticKinds.def

Chris Lattner clattner at apple.com
Thu Aug 30 15:29:29 PDT 2007


On Aug 30, 2007, at 3:23 PM, Neil Booth wrote:

> Chris Lattner wrote:-
>
>> On Fri, 31 Aug 2007, Neil Booth wrote:
>>>> Author: lattner
>>>> Date: Thu Aug 30 12:45:32 2007
>>>> New Revision: 41613
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=41613&view=rev
>>>> Log:
>>>> implement initial sema support for __builtin_offsetof
>>> It looks like clang has GCC's bug of forgetting that -> operator
>>> in addition to [] operator can be used in offsetof.
>>
>> It does!  Can you give an example that uses it?
>
> I thought it would be instructive to figure that out yourself :)
>
> struct s { struct { int t; } x[2]; };
> int f (void) { return offsetof (struct s, x->t); }

Are you sure that's valid?  C99 has a maddeningly brief discussion of  
what is valid in offsetof.  By this logic, wouldn't offsetof (struct  
s, x+1) also be valid?

-Chris



More information about the cfe-commits mailing list