M
Malcolm McLean
If you implement threads, you've got to suppose that there is some mechanismOn Fri, 15 Nov 2013 01:29:52 -0800 (PST), Malcolm McLean
Unless the Standard states somewhere that when one uses
multi-threading, all objects become volatile. In such a case sequence
points become meaningless and we no longer have an abstract machine.
In that case, every single operation involving operands would invoke
undefined behaviour.
which prevents them stepping over each other's memory accesses. If this
isn't provided, then indeed you can't say anything about the behaviour of
the program.
In the case of overlapping rand() calls, there are two main possibilities,
a read of the high byte, then a write to the low byte by the other thread,
followed a read of the written low byte, or the reverse, leading to two
different results. But the reconstituted word could conceivably form a
trap representation, terminating the program with an error message. So it's
exactly the same as undefined behaviour.