Evaluation of if's

Jon J Thaler DOCTORJ at SLACVM.SLAC.STANFORD.EDU
Thu Jun 6 03:51:07 AEST 1991


In article <1991Jun4.233928.5185 at athena.mit.edu>, scs at adam.mit.edu (Steve
Summit) says:

>> [...discussion of this expression deleted...]
>>       if ( (i=1) == (i=2) )

>Of course it's undefined.  (It contains two side effects not
>separated by a sequence point.)  Given that the behavior is
>undefined, I'd say it's fairly pointless to catalog the behavior
>of available compilers.  As Kernighan and Ritchie point out, and
>I am fond of quoting, "if you don't know how they are done on
>various machines, that innocence may help to protect you."

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.



More information about the Comp.lang.c mailing list