Can analysis detect undefined expressions?

Dale Worley worley at compass.com
Tue Jun 18 23:55:21 AEST 1991


In article <14206.285B7688 at stjhmc.fidonet.org>, Dave.Harris at f14.n15.z1.fidonet.org (Dave Harris) writes:
> An extended example so that I can think clearly here:
>      (j = ((i=1) == (i=2))) == (j = ((i=3) == (i=4)))
> Assumedly, i can end up as 1,2,3, or 4.  j should be 0.  The grouping is such 
> that i=4, i=2, i=3, i=1 won't happen without breaking any laws.  right?

Sorry to belabor this yet again, but there is no requirement in Ansi C
that i have one of the values 1, 2, 3, or 4.  The effect of this
statement is "undefined", which means that the implementation can do
*anything*, including giving i the value 100, core dumping, or
starting World War III.  Ditto for j.  The mere fact that none of
these actions are mentioned in the statement is irrelevant.

Dale Worley		Compass, Inc.			worley at compass.com
--
I'd sign on for the War on Drugs if they'd include alcohol and
nicotine on the official hit list.



More information about the Comp.lang.c mailing list