sizeof a struc field

davies at uicsrd.csrd.uiuc.edu davies at uicsrd.csrd.uiuc.edu
Fri Oct 13 07:16:00 AEST 1989


gwyn at smoke.BRL.MIL writes re: using sizeof((type *)0->field:
**
**No, there IS no type information, because the construct is
**officially meaningless.  You THINK you know what type was MEANT,
**but the compiler is not obliged to mimic your thought processes.
**
**This is not an issue about sizeof, but rather about ->.

If it is "officially meaningless" to use (type *)0->field,
would it be "officially meaningful" to instead substitute
(type *)1->field?
After all, the pointer is no longer NULL, so it must be ok, right?

This whole discussion seems a bit abstract - can anybody cite references
from the standard or examples of compiler behaviour when confronted
with something like this?



More information about the Comp.lang.c mailing list