Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond From: diamond@csl.sony.co.jp (Norman Diamond) Newsgroups: comp.lang.c Subject: Re: sizeof a struc field Message-ID: <10973@riks.csl.sony.co.jp> Date: 19 Oct 89 01:51:27 GMT References: <7710@microsoft.UUCP> <11086@smoke.BRL.MIL> <131@dtoa3.dt.navy.mil> <11227@smoke.BRL.MIL> <7678@cdis-1.uucp> <11263@smoke.BRL.MIL> <10960@riks.csl.sony.co.jp> <11280@smoke.BRL.MIL> <277@dsi.COM> <11316@smoke.BRL.MIL> Reply-To: diamond@riks. (Norman Diamond) Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 32 In article <277@dsi.COM> dave@dsi.UUCP (Dave Rifkind) writes: >>"Null pointer" is not a syntactic >>concept--it's meaningful only at runtime. In article <11316@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >I said that dereferencing a null pointer CONSTANT was meaningless, >and it is EXACTLY the kind of thing I want compilers to check for >me at compile time. There is no service being rendered by a compiler, >when it is in a position to detect a usage error at compile time, >silently proceeding to generate code that may blow up at run time. (Dereferencing a null pointer NON-CONSTANT is just as meaningless.) Sure, I'd be glad to have the compiler help diagnose errors at compile time, under any condition where it knows appropriate information. This entire argument concerns a null pointer constant inside a _sizeof_ expression. Mr. Gwyn, if your compiler is in a position to detect a usage error at compile time, but it silently proceeds to generate code TO EVALUATE SIZEOF that may blow up at run time, or if it even generates code TO EVALUATE SIZEOF which will not blow up at run time, I'd say you have a pretty bad compiler. The entire reason this argument exists is that _sizeof_ does not generate any code, it does not dereference a null pointer, and it doesn't even stick a null segment pointer into a segment register. Until this posting of Mr. Gwyn's, I thought both sides had valid points. -- Norman Diamond, Sony Corp. (diamond%ws.sony.junet@uunet.uu.net seems to work) Should the preceding opinions be caught or | James Bond asked his killed, the sender will disavow all knowledge | ATT rep for a source of their activities or whereabouts. | licence to "kill".