Implementation-DEPENDENT code (was:strcpy)

Barry Margolin barmar at think.COM
Fri Apr 8 17:35:34 AEST 1988


In article <4331 at ihlpf.ATT.COM> nevin1 at ihlpf.UUCP (00704a-Liber,N.J.) writes:
[Example of code that depends on old value of a variable from the
previous time a block was exited.]
>The reason is that j is declared inside a block, and this block is entered
>and exited through each iteration of the while loop.

I know of one implementation where that example probably won't work,
although I haven't tried it yet.  The Symbolics C compiler initializes
automatic variables that do not have an explicit initializer) to a
special "undefined" value, and traps attempts to take the value.

The compiler also does a little flow analysis and warns you if it
looks like your code references a variable before setting it
(unfortunately, it is a bit overeager in this regard, and warns about
some cases that are obviously valid to a human reader (note that this
comment is based on experience with the beta test version of the
compiler, and it may have been improved in the final version)).


Barry Margolin
Thinking Machines Corp.

barmar at think.com
uunet!think!barmar



More information about the Comp.lang.c mailing list