home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13266 < prev    next >
Encoding:
Text File  |  1992-09-07  |  1.8 KB  |  46 lines

  1. Newsgroups: comp.lang.c
  2. From: jes@grendel.demon.co.uk (Jim Segrave)
  3. Path: sparky!uunet!pipex!demon!grendel.demon.co.uk!jes
  4. Distribution: world
  5. Subject: Re: strcpy implementation question
  6. References: <PINKAS.92Sep3173643@skywalker.intel.com>
  7. X-Mailer: cppnews $Revision: 1.14 $
  8. Organization: None
  9. Lines: 32
  10. Date: Fri, 4 Sep 1992 21:59:17 +0000
  11. Message-ID: <715669157snx@grendel.demon.co.uk>
  12. Sender: usenet@gate.demon.co.uk
  13.  
  14.  
  15. In article <PINKAS.92Sep3173643@skywalker.intel.com> pinkas@skywalker.intel.com (Israel Pinkas) writes:
  16. >  ...
  17. > ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
  18. > RK> This is wrong.  It isn' the source or the destination that cares, it is
  19. > RK> strcpy() that cares.  strcpy() MUST NOT READ any uninitialised memory
  20. > RK> locations.
  21. > Why not.  There is a difference betwenn uninitialized and unallocated.  For
  22. > example, with the declaration:
  23. >     int a[5];
  24. > inside a block.  a[0] is uninitialized, but a[5] may be unallocated.
  25. > Uninitialized memory belongs to the process, it just doesn't have a known
  26. > or predictable value.  It is still legal to access it.  Unallocated memory
  27. > doesn't belong to the process, and will probably cause an execution error
  28. > if accessed.
  29. > -Israel
  30.  
  31. It is quite practical and often useful for a machine to pre-initialise
  32. memory to detect attempts to read uninitialised variables - I have seen
  33. references to systems which did this. Typically, in a system with memory
  34. parity checking, the system presets the parity of the process memory to
  35. a 'fault' value, then loads the program. Reading any location which has
  36. not been written (or loaded from the executable) generates a parity fault.
  37. This is a very useful hardware assist for debugging. And, on such a system,
  38. RK is quite right - you must *not* read unintialised memory. 
  39. --
  40. Jim Segrave (Segrave Software Services)     jes@grendel.demon.co.uk
  41.  
  42.