From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,f79df321ef1d2c00 X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1992-06-18 00:44:30 PST Path: sparky!uunet!munnari.oz.au!mips!mips!swrinde!cs.utexas.edu!sun-barr!news2me.ebay.sun.com!grapevine.EBay.Sun.COM!sunicnc.France.Sun.COM!smckinty From: smckinty@sunicnc.France.Sun.COM (Steve McKinty - Sun ICNC) Newsgroups: comp.sys.dec Subject: Re: Porting to Alpha VMS Message-ID: <11q1opINNrmv@grapevine.EBay.Sun.COM> Date: 18 Jun 92 13:06:33 GMT References: <1992Jun16.131316.23012@nntpd.lkg.dec.com> <1992Jun17.101358.2044@lsl.co.uk> <1992Jun18.102322.2054@lsl.co.uk> Sender: smckinty@hardy (Steve McKinty - Sun ICNC) Organization: Sun Technologies Enterprise Inc. NNTP-Posting-Host: hardy.france.sun.com In article <1992Jun18.102322.2054@lsl.co.uk>, robin@lsl.co.uk (Robin Fairbairns) writes: > In article , cmr@world.std.com (Charles M Richmond) writes: > > [quotes from me deleted] > > > > One of the gotchas that I ran into in a major port from Vax/Ultrix to > > Risc/Ultrix (more than 750,000 lines), was that the coders had used > > the availability of address "0" to skip checks for null pointers. The > > other problem was that structures were cast as byte streams and vice > > versa, which enforced the coders idea of how the structures were packed. > > Quoting from my (non-final) copy of the C standard, para 3.2.2.3: "An > integral constant expression with the value 0, or such an expression > cast to type void *, is called a _null pointer constant_. .... Such a > pointer, called a _null pointer_, is guaranteed to compare unequal to > any object or function." > I suspect the problem isn't with null pointer constants, but with pointers containing a zero value. If you dereference such a pointer (and thus access location zero) the standard doesn't say what will happen. On a VMS VAX you'll get an memory access violation, because the first 512 bytes are intentionally inaccessible to catch this sort of error/laziness. On an IBM PC nothing much will happen unless you're using the large memory model and writing to location 0, in that case you'll trash your hard disk. I don't know about VAX/Ultrix & Alpha/whatever, but I'd hope that location 0 would be inaccessible, the VMS method is very useful for trapping programming mistakes with pointers. Steve