Evaluation of if's

Henry Spencer henry at zoo.toronto.edu
Thu Jun 6 06:25:59 AEST 1991


In article <91156.095107DOCTORJ at SLACVM.SLAC.STANFORD.EDU> DOCTORJ at SLACVM.SLAC.STANFORD.EDU (Jon J Thaler) writes:
>>>       if ( (i=1) == (i=2) )
>
>When must a compiler issue warnings or other error messages? It seems to
>me that since this expression is recognizable as an error, a compiler
>'ought' to warn the user.  As far as I can tell, this does not seem to be
>required by the standard.

The problem is that the references to the same variable may be done via
pointers etc., and might be very difficult to recognize at compile time.
So it is not realistic to demand that a compiler diagnose all violations
of this particular rule.

Of course, it is nice if it *does* diagnose them when it notices them.
In general, most any "undefined" item in the standard is something that
a good compiler ought to *try* to notice and report.

The only requirement the standard puts on diagnostics is that a program
which violates the standard's official constraints shall draw at least
one complaint.  Implementations vary so enormously (consider compilers
vs. interpreters, for example) that it was not considered practical to set
any more specific requirements.
-- 
"We're thinking about upgrading from    | Henry Spencer @ U of Toronto Zoology
SunOS 4.1.1 to SunOS 3.5."              |  henry at zoo.toronto.edu  utzoo!henry



More information about the Comp.lang.c mailing list