On 28/06/17 18:36, Richard Earnshaw wrote: > thread2 is blissfully unaware of the fact that by using CAS directly on > 'a' it has broken the requirement in f() that an object must be locked > before it can be dereferenced. I don't undestand, though; wouldn't this be something which falls wholly to the *user* to get right? why is the compiler concerned? If I create a variable which I make thread safe with locks and then in one case I don't use those locks, this is my problem, not the compilers. This matter with CAS/locks seems much the same.