[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

Neil Booth neil at daikokuya.co.uk
Thu Aug 30 15:55:56 PDT 2007

Chris Lattner wrote:-

> >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?

Hmm, I guess it would.  Yuk.

The std for this is written in ridiculously vague language
that could be read as intending only a single identifier as the
second argument.  See e.g. (last one by yours truly):




In each thread different members of the C committee have said that
only an identifier was intended.  To me that only begs the question
of why the language is so opaque - surely easier to just say it
shall be an identifier?

But your example has convinced me that restricting this offsetof to
just an identifier is probably a good idea - accepting generic
expressions can get out of control.

FWIW Viro had sparse accept ->



More information about the cfe-commits mailing list