This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH: Fix PR 13275
On Wed, 17 Dec 2003, Richard Henderson wrote:
> > I don't see anything in the C standard to say that offsetof needs to work
> > for anything other than a simple member of the specified structure type.
>
> I don't see a definition of "member-designator" anywhere, other than
> "&t.<member-designator>" must be valid. I'd think this is similar to
> your argument that something other than a simple type tag can be used
> as the first argument of offsetof.
It seems to say that member-designator is a member of the structure type
type (not an array element, etc.). Both these matters could do with DRs.
> > ... and we should specify when it is meant to be what sort of constant
> > expression depending on the expressions in array indices (and on the other
> > GNU extension of variable-length structures).
>
> Yes. While we aren't actually implementing integer constant expressions
> yet, we shouldn't open the door too wide. Personally I think saying that
> the array indicies themselves must be integer constant expressions would
> be sufficient.
I.e., that it is an error to use offsetof if they aren't?
(The standard is also silent on whether address constants can use indices
that are arithmetic constant expressions but not integer constant
expressions. Another point for any subsequent revision of my analysis of
the problems with constant expressions.)
--
Joseph S. Myers
jsm@polyomino.org.uk