Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!image.soe.clarkson.edu!news From: cline@cheetah.ece.clarkson.edu (Marshall Cline) Newsgroups: comp.lang.c++ Subject: Re: references to dereferenced null pointers Message-ID: Date: 4 Apr 90 19:13:42 GMT References: <5764@videovax.tv.tek.com> <15126@cbnews.ATT.COM> <10647@alice.UUCP> Sender: news@sun.soe.clarkson.edu Reply-To: cline@sun.soe.clarkson.edu (Marshall Cline) Organization: (I don't speak for the) ECE Dept, Clarkson Univ, Potsdam, NY Lines: 20 In-reply-to: cline@cheetah.ece.clarkson.edu's message of 4 Apr 90 18:25:07 GMT In article cline@cheetah.ece.clarkson.edu (Marshall Cline) writes: (in other words, I just wrote): > I'm suspect you meant, in the first case, to cast both pointers to > char* (to add/subtract bytes not structs/ints), then cast (char*)&X::b > to an int, then subtract, then cast the difference back to X* (phew!). But Andrew Koneig recently pointed out that casting a pointer-to-member to an int is undefined (it must be this way otherwise the first member of a struct could come out 0, which is reserved to mean "ptr to nowhere"). My algorithm (cast, cast, subtract, cast) is therefore incorrect. Apologies. Marshall Cline -- =============================================================================== Marshall Cline/ECE Department/Clarkson University/Potsdam NY 13676/315-268-3868 cline@sun.soe.clarkson.edu, bitnet: BH0W@CLUTX, uunet!clutx.clarkson.edu!bh0w Career search in progress: ECE faculty. Research oriented. Will send vitae. ===============================================================================