Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: sizeof a struc field Message-ID: <1423@crdos1.crd.ge.COM> Date: 24 Oct 89 17:11:50 GMT References: <7710@microsoft.UUCP> <11316@smoke.BRL.MIL> <7685@cdis-1.uucp> <2488@munnari.oz.au> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: GE Corp R&D Center Lines: 15 In article <2488@munnari.oz.au>, ok@cs.mu.oz.au (Richard O'Keefe) writes: | I'm sure I'll be corrected if I'm wrong, but isn't the actual restriction | that the argument of "sizeof" must be an L-value in ANSI C? If I'm right | about that, then the problem is not that sizeof ((struct foo*)NULL)->field | may "blow up", but that ((struct foo*)NULL)->field is not an L-value. 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. -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon