Path: utzoo!attcan!uunet!cs.utexas.edu!usc!apple!amdahl!vohra From: vohra@uts.amdahl.com (Pavan Vohra) Newsgroups: comp.unix.wizards Subject: Re: Referencing NULL pointers Message-ID: <32UP02Eg3d=801@amdahl.uts.amdahl.com> Date: 11 Jul 89 07:35:39 GMT References: <19367@paris.ics.uci.edu> <1891@auspex.auspex.com> Reply-To: vohra@amdahl.uts.amdahl.com (KC) Organization: Amdahl Corporation, Sunnyvale CA Lines: 30 In article <1891@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes: >> Apparantly, on other machines this is perfectly valid, since I see >> quite a lot of this in code created on certain non-sun machines. > >No, it's not valid, it just happens to work - and only on *some* other I would say that the code is valid. Try a rewrite: "x= ((struct somestruct *)0)->somefield". It can be convenient to make the first page (or whatever unit) inaccessible to cause errors for structures that are smaller than that unit. Maybe Sunos does this. It looks like in the case of UTS 1.2, at least our copy of it, the above would not cause an error, but because the default magic has the code segment read-only, "t->somefield" would probably cause an error provided that the offset of somefield is small. Anyway, it is the operating system that makes the action that the process takes valid or invalid. KC borrowing vohra. -- --- Pavan Vohra {..hplabs|ames|ihnp4|decwrl}!amdahl!vohra Amdahl Corporation Sunnyvale, CA 94086-3470 ---