machine generated code and chatty compilers

P E Smee exspes at gdr.bath.ac.uk
Thu Jan 11 20:57:15 AEST 1990


In article <923 at thor.wright.EDU> econrad at thor.wright.edu writes:
>From article <1471 at mdbs.UUCP>, by wsmith at mdbs.UUCP (Bill Smith):
>> People are not the only entities that generate code for C or C++ compilers.
>
>So turn the warning suppression flag on for automatic-generated code.

This gets to be a religious argument about the proper task for compilers.
My opinion is that the flag should be a 'warning generation' flag.  That
is, by default the warnings should be suppressed; if you want them you
should ask for them.  NOTE that I am talking about WARNINGS, not ERRORS.

My rationale is that the job of a compiler is to take a program source
as input, and to check it *against the language spec*.  If the source
is conformant to the spec, the compiler should silently generate the
appropriate code, as requested by the source generator (be it person, or
tool).  If the source is NOT conformant to the spec, the compiler should
diagnose ALL and ONLY the errors.  (I'll forgive it, though, if SOME
errors screw up its internal state enough that it can't recover, and so
puts out an error and terminates without checking further.)

I would say that if a compiler puts out a warning or error message by
default in response to a VALID piece of code, simply because the
compiler is not convinced that I really wanted to say that, then that
is a bug in the compiler.  The fact the the compiler writer couldn't
see any use for some valid construct does not mean there is no valid
use for it.

The one exception I would be willing to make, is to allow the compiler
also to complain about things which are valid within the language, but
which are (provably at compile time) impossible on the machine for
which it was written.  For example, trying to address an odd location
as an int, if the hardware requires ints to be even-address aligned.

And, as implied at the start, I have no objections to the compiler
allowing you to ask for more warnings; but it shouldn't try to ram them
down your throat.

-- 
Paul Smee, Univ of Bristol Comp Centre, Bristol BS8 1TW, Tel +44 272 303132
 Smee at bristol.ac.uk  :-)  (..!uunet!ukc!gdr.bath.ac.uk!exspes if you MUST)



More information about the Comp.lang.c mailing list