Can analysis detect undefined expressions?
der Mouse
mouse at thunder.mcrcim.mcgill.edu
Wed Jun 26 19:39:35 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:
>> (j = ((i=1) == (i=2))) == (j = ((i=3) == (i=4)))
>> 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.
> 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.
Let's rephrase that...I too would quickly scrap any compiler that went
to the additional work of embedding unnecessary code. Period.
However, if the architecture is such that assignments can happen in
parallel, i could wind up holding 1|2|3|4, which happens to be 7. Or
perhaps 1&2&3&4, which is 0. Or maybe i doesn't get changed at all.
Or perhaps something else, including a run-time assignment collision
fault from the parallel assignment hardware.
> I would really like to see an example of code accomplishing
> completely unexpected behavior as in setting i equal to 5.
ON * RENDEZVOUS ; rendezvous (end of last statement)
ON 0 MOV $1,i ; i=1
ON 1 MOV $2,i ; i=2
ON 2 MOV $3,i ; i=3
ON 3 MOV $4,i ; i=4
ON 4 MOV $0,j ; j = ((i=1) == (i=2))
ON 5 MOV $0,j ; j = ((i=3) == (i=4))
ON * RENDEZVOUS ; rendezvous again
Or the optimizer might save code space by doing
ON * RENDEZVOUS
ON 0 MOV $0,j ; j = ((i=1) == (i=2))
ON 5 MOV $0,j ; j = ((i=3) == (i=4))
ON 1,2,3,4 MOV %PROCID,i ; i=1 / i=2 / i=3 / i=4
ON * RENDEZVOUS
Of course, the hardware to execute that code probably doesn't exist at
the moment, but that's beside the point. It's hardly a far-fetched
architecture.
der Mouse
old: mcgill-vision!mouse
new: mouse at larry.mcrcim.mcgill.edu
More information about the Comp.lang.c
mailing list