B
Barry Schwarz
Jerry Coffin said:[ ... ]
i not speak about standards, i speak about a real cpu
if one 386 cpu of state X(eax=1, ebx=19, ecx=20 ...)
read the binary of "add eax, ebx"
the result will be always the state of cpu
X'(eax=20, ebx=19, ecx=20 ...)
Yes, but what if what's executed is 'add eax, [ebx]' instead? If ebx
happens to point to uninitialized memory,
i see the hardware 386cpu, the memory that can read, like a system
if this system has one state
State(0)={X(eax=20, ebx=19, ecx=20 ...)
Memory={1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,1 ...}
}
if the cpu read the instruction
'add eax, [ebx]'
State(1)={X(eax=21, ebx=19, ecx=20 ...)
Memory={1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,1,...}
}
there is not UB
it is like a phisical system
if i know the position in the time 0 i know the position in the next time 1
UB in that system could be only for the fail of cpu
Except you will never know all the states. Every time you run the
program, the clock will be different. If you are running on a typical
system, you share the CPU, memory, and OS with numerous other tasks
running "simultaneously" and their states will not be the same from
one execution to the next.
If you run the program in the morning and it produces a result of 42
and in the afternoon and it produces 24 or you recompile it on an odd
numbered Thursday during a full moon and it now produces 69 or you
change compilers and it now produces 7734, there is no way for you to
define the behavior of the program. Hence, its behavior is undefined.