The importance of showing ALL of the code in C

From: Ethan Dicks <erd_6502_at_yahoo.com>
Date: Wed Feb 6 16:34:37 2002

--- "Fred Cisin (XenoSoft)" <cisin_at_xenosoft.com> wrote:
> On Wed, 6 Feb 2002, John Chris Wren wrote:
> ...it's liable to generate a runtime error
>
> With, OR WITHOUT, an MMU, it is legal C code!
> int A[10];
> int N;
> . . .
> A[10] = 0;
> will NOT generate a runtime error.

True, but additionally, *depending* on A[10]=0 setting N to 0 as a side-
effect is not reliable. C won't trap that as an error, but if you
are trying it on purpose and a particular implementation does not
order variables in memory in the order you expect, or puts gaps in to
maintain data alignment, etc., you have no right to be surprised.

> "If you want to shoot yourself in the foot, C provides you with unlimited
> ammunition."

As does assembler. ;-)

-ethan


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com
Received on Wed Feb 06 2002 - 16:34:37 GMT

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