Referencing NULL pointers

David C. Rein dave at mobile.UUCP
Thu Jul 13 03:38:37 AEST 1989


In article <32UP02Eg3d=801 at amdahl.uts.amdahl.com>, vohra at uts.amdahl.com (Pavan Vohra) writes:
> In article <1891 at auspex.auspex.com> guy at 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.
> [..stuff deleted..]
> Anyway, it is the operating system that makes the action that the
> process takes valid or invalid.
> 
> KC borrowing vohra

   Well, since the operating system we are discussing here is *NIX, 
   I don't understand your comment of 'the operating system that makes the 
   action...valid or invalid', or are we just dropping the idea of
   portability?  The fact that you might be able to access 0 is meaningless.
   In AIX PS/2, if you do a (i.e.) printf("%s", (char *)0); you'll get:

   L

   since this is the magic number for AIX executables.  Basically, a program
   that makes the assumption that it can dereference possibly uninitialized
   pointers is not a well written program (in my opinion).  And, most
   important of all, since not all *NIX systems allow for this (as they should
   not!), it hinders the portability of code, which is one of the foundations of
   *NIX!
                                                        Dave Rein
----------------------------------\  /-----------------------------------------
UUCP: ..!kodak!gizzmo!lazlo!\      \/   "It just goes to show what you can do 
            mobile!dave            /\         if you're a total psychotic"
Domain: dcr0801 at ritcv             /  \           -- Woody Allen
---------------------------------/    \----------------------------------------



More information about the Comp.unix.wizards mailing list