Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!ucbvax!decwrl!decvax!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.unix.wizards Subject: Re: Referencing NULL pointers Message-ID: <621@lakart.UUCP> Date: 17 Jul 89 14:58:17 GMT References: <1382@bruce.OZ> Organization: Lakart Corporation, Newton, MA Lines: 28 vohra@uts.amdahl.com (Pavan Vohra) sez: > I would say that the code is valid. > > Try a rewrite: "x= ((struct somestruct *)0)->somefield". I have never been comfortable with this construct, and would submit the following as a "safer" replacement: struct somestruct stuff; x = (char *) (&stuff.somefield) - (char *) (&stuff); Comments????? The above assumes that somefield is not an array: if it is you can take your pick of: stuff.somefield and: &stuff.somefield[0] -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+