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