sizeof(((struct_type *)0)->member_name)

Henry Spencer henry at utzoo.UUCP
Wed Dec 17 06:44:50 AEST 1986


> >> Can I do something like this:
> >>     char a[sizeof(struct name *)0->element];
> 
> > Don't think so.
> 
> Why not?  Note what H&S have to say about sizeof, on page 153...
> 
> Note that the evaluation of an indirection of the null pointer is indeed
> illegal.  But that isn't what is going on here...

Hmmm...  On thinking this over and consulting the Scriptures, I think
Wayne is right and the construct is legal.  It gives me the creeps, and
I'd never use it, but I think it's legal.  Recent X3J11 drafts are quite
careful to say that certain operators must not be *evaluated* in constant
expressions, rather than that they must not be present at all.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry



More information about the Comp.lang.c mailing list