Volatile (was Re: observability)

Mark Horton mark at cblpf.ATT.COM
Fri Sep 15 01:50:57 AEST 1989


P E Smee writes:
> >one might ask why you would want to write a chunk
> >of code that has ZERO effect.

> I sometimes do this during program development. I declare the data
> structures and write the code that operates on them, leaving the i/o
> to worry about later. I may want to compile at this point to check
> for errors in the code.

If all you want is syntax and semantic checking, you're going to get
that unless the code is surrounded by something like
	#ifdef notdef
	(useless code)
	#endif /* notdef */
which the compiler had better ignore - it might contain comments.
(I hope pANS hasn't outlawed making comments this way and otherwise
neutralizing old code that you might want again someday.)

For the compiler to determine that a particular piece of code is
useless, it has to perform a fair amount of analysis.  It has to
process the preprocessor, syntax, semantics, generate code, and
do some kind of analysis.  A syntax error will certainly be detected
and reported, as will a static semantic error.  Runtime errors are
going to be hard to detect without I/O statements, unless the thing
divides by zero or something without any I/O.  I don't see how any
"useless code deletion" feature is going to get in your way.  It
can't determine that the code is useless without understanding it.

Of course, you could always just use a syntax directed editor.

	Mark



More information about the Comp.std.c mailing list