As I said in the direct answer: your mutex does not protect anything IMHO. The char array that * bin is placed into can be modified during int-access, so depending on your computer, you wonβt even get a consistent representation in the memory that you wanted to access. Let's get back to your question: the compiler does not convert the source code into the sequence that you intended, but it can very well produce a machine language, which essentially behaves the way your source code does. If it is capable of checking function locks, unlocking and hibernating (which appear to be macros anyway), and can infer that there is no side effect for the memory locations involved, and there is no definite implementation definition for calls, for example. sleep (), which will display temporary ("cached", although the standard does not use this term) values ββare invalid, then it has the right to produce a sequence of commands, such as the one you gave. C (before C99) is essentially single-threaded, and the compiler can use any optimization strategy that it wants, while the code behaves βas it were,β it will work on an ideal hypothetical machine C. The sequence points that Jens mentioned do not affect correct under single-thread conditions: the compiler can hold foo in the register during the whole function or it can even alias foo.i with the memory address pointed to by * bin, so this code (at least I think it will not demonstrate this behavior is for most wa compilers).
slartibartfast
source share