Can analysis detect undefined expressions?

Mark Brader msb at sq.sq.com
Sun Jun 23 16:03:37 AEST 1991


> >      (j = ((i=1) == (i=2))) == (j = ((i=3) == (i=4)))
> Not arguing that the result is undefined as you say.  But....  I for one
> would quickly scrap any compiler that went to the additional work of 
> embedding code to yield a value of anything other than 1,2,3 or 4 for i.

On the other hand, I for one would welcome with open arms a compiler
that made those checks at compile time and exercised its right to
*refuse to compile it* in the first place.

(As has been pointed out, this becomes arbitrarily difficult if the
expression involves things like indirection.  I don't care.  I just
want the compiler to reject a[i++] = i, x = a[i++]+b[i++], the above
expression, and other such cases that *are* easily diagnosed.  Even
Saber-C (3.0.1) misses these, unless maybe I have some option set wrong.)
-- 
Mark Brader		     "It is impractical for the standard to attempt to
SoftQuad Inc., Toronto	      constrain the behavior of code that does not obey
utzoo!sq!msb, msb at sq.com      the constraints of the standard."  -- Doug Gwyn

This article is in the public domain.



More information about the Comp.lang.c mailing list