[Bug c++/13275] [3.4 regression] Implementation of offsetof macro

jsm at polyomino dot org dot uk gcc-bugzilla@gcc.gnu.org
Wed Dec 3 10:24:00 GMT 2003


------- Additional Comments From jsm at polyomino dot org dot uk  2003-12-03 10:24 -------
Subject: Re:  [3.4 regression] Implementation of offsetof
 macro

On Wed, 3 Dec 2003, nathan at gcc dot gnu dot org wrote:

> I have come to the conclusion that one *cannot* implement offsetof without
> a builtin of some kind. You need something like
> #define offsetof(type,member) \
>    __builtin_offsetof (__builtin_offset_obj(type).member)
> You need cooperation from the parser, so that the .MEMBER part is
> looked up in the context of TYPE - hence the __builtin_offset_obj part.

I don't see the need for having both __builtin_offsetof and
__builtin_offset_obj rather than the obvious __builtin_offsetof(type,
member).  Of course the syntax means that __builtin_offsetof is actually a
keyword treated specially by the parser, rather than a built-in function,
and so can cause whatever special treatment is needed in the parser;  
that's just like __builtin_va_arg already is.

(Both C and C++ should have __builtin_offsetof, preferably with the same
syntax, for a correct implementation.)



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13275



More information about the Gcc-bugs mailing list