Path: utzoo!utgpu!watmath!datanguay From: datanguay@watmath.waterloo.edu (David Adrien Tanguay) Newsgroups: comp.lang.c Subject: Re: sizeof a struc field Message-ID: <30488@watmath.waterloo.edu> Date: 19 Oct 89 10:25:37 GMT References: <7710@microsoft.UUCP> <11086@smoke.BRL.MIL> <131@dtoa3.dt.navy.mil> <11316@smoke.BRL.MIL> <1234@crdos1.crd.ge.COM> Reply-To: datanguay@watmath.waterloo.edu (David Adrien Tanguay) Organization: U. of Waterloo, Ontario Lines: 26 In article <1234@crdos1.crd.ge.COM> davidsen@crdos1.UUCP (bill davidsen) writes: ] ]Here's what the standard says (3.3.3.4): ] [quotes the standard] ] ]If the expression is not evaluated the pointer is not dereferenced and ]there is no problem as far as hypothetical hardware which checks for ]this. I see nothing which I can read to forbid the original construct ]or indicate that it might not be valid in this case. The meaning of an ]incomplete type is spelled out in 3.1.2.5 and a null pointer with a ]cast isn't shown. I therefore conclude that the construct of the ]original poster is valid C as specified by the standard. See also section 3.3.2.3, on the '->' and '.' operators. It eventually says "...designates a member of a structure or union object." and "... is an lvalue.". ((struct foo *)0)->elem does not designate an object. Is there a clearer indication elsewhere? ]I also really ]wonder why sizeof doesn't return "unsigned int" but I suspect i wouldn't ]like the answer. Unsigned int might not be large enough to hold the size of an object. E.g., an IBM PC with huge objects. David Tanguay