Can analysis detect undefined expressions?
Jonathan Gingerich
jon at maui.cs.ucla.edu
Sat Jun 22 02:52:26 AEST 1991
In article <14489.2861906B at stjhmc.fidonet.org> Dave.Harris at f14.n15.z1.fidonet.org (Dave Harris) writes:
>In a message of <Jun 18 20:31>, Dale Worley (1:114/15) 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.
>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. It
>would mean the compiler would have to detect the undefined statement first
>before it could even do this. ...
Not if it were setting i on 4 CPUs run in parallel! Jon.
More information about the Comp.lang.c
mailing list