The importance of showing ALL of the code in C

From: Carlini, Antonio <Antonio.Carlini_at_riverstonenet.com>
Date: Wed Feb 6 16:48:01 2002

> Fred Cisin (XenoSoft) write:
>
>With, OR WITHOUT, an MMU, it is legal C code!

        Legal in the sense that the compiler cannot
        spit it out. It does not, however, have an
        implementation independent meaning
        (i.e. different things can happen on different
        platforms).

> int A[10];
> int N;
>. . .
> A[10] = 0;
>will NOT generate a runtime error.

        While A[10] has a clear meaning
        (the next int in memory after A[9])
        that doesn't mean that:
         
        (a) you have any idea which (if any)
              of your other variables may be trodden on
              (in particular there is no way you can
               know where N will be in memory in
               relationship to A[])
        or

        (b) that you cannot seg fault under some
             circumstances on some machines
             (as a simple example, consider the
              case of an embedded system where
              A[9] happens to land at the exact
              top of your accessible memory).

        Antonio
Received on Wed Feb 06 2002 - 16:48:01 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:34:44 BST