Skip to contentSkip to conversation

C undefined behavior fix

PATCH [email protected] 1 participant 1 message Jan 9, 2002

lore
Share & tools
lore
#0 lore raw

<<Yes, thank you, that part was obvious already. The question pertained to the fact that nobody outside compiler-visible code was being handed an address for b, and so the compiler could (if it wanted to) prove under pretty broad assumptions that nobody could *find* b to make the change in the first place.

Quoted 1 line
Quoted 1 line

Suppose that a hardware emulator is used to change the value of b (IT knows the address) at the point of:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

here b changes

The reason was precisely to test a different value for b. This should work if b is volatile. So the compiler's proof is flawed. The whole point of volatile is that ALL such proofs are forbidden for volatile objects.