C Arrays

  1. A C array is the name of a piece of memory. Specifically it is a name for the starting address of this block of memory.

  2. A C array can be allocated on the heap (persistent) or on the stack (temporary). A stack array can therefore be allocated within a method and returned to the caller. This results in the receiver of the array address getting an invalid heap address - without noticing it.

  3. A C array cannot be assigned to another array because it is no reference. But the contents of one array can be copied into another - hopefully respecting the array limits.

  4. No exception is thrown if the array is accessed with an index lower or higher than the array definition. No runtime check is performed by the C runtime system. Adjacent memory is simply overwritten and can result in spurious bugs. This approach trades safety for speed.