sizeof a struc field

Chris Torek chris at mimsy.umd.edu
Wed Oct 25 04:35:41 AEST 1989


>In article <2488 at munnari.oz.au> ok at cs.mu.oz.au (Richard O'Keefe) writes:
>>... isn't the actual restriction that the argument of "sizeof" must be
>>an L-value in ANSI C? ... ((struct foo*)NULL)->field is not an L-value.

In article <1423 at crdos1.crd.ge.COM> davidsen at crdos1.crd.ge.COM
(Wm E Davidsen Jr) writes:
>The standard says that you may take the sizeof an array, so the
>expression most definitely does not have to be an lvalue. You can also
>take sizeof something const.

According to the standard, arrays and consts are `non modifiable
lvalue's (which rather contradicts the original meaning of l-value!).

Anyway, I happen to think that `sizeof(*(type *)junk)' and similar
constructs ought to be acceptable for any parse-able, cast-able `junk'.
The standard happens to disagree.  This is Just One Of Those Things.
-- 
`They were supposed to be green.'
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list