* Samuel Tardieu:
> On 27/10, Florian Weimer wrote:
>
> | (I can't reproduce the conditional store with my GCC 4.2 installation,
> | though.)
>
> You need "-O -fno-inline" to trigger it on this particular example
> (you don't need "-fno-inline" if you put "Lock" in a separate package).
Ah, thanks. I see it now.
If not for Ada, we need to fix it for Java. The following snippet shows
the same problem:
class C {
static volatile boolean flag;
static int shared;
public void maybe_increment() {
if (flag)
++shared;
}
}
_ZN1C15maybe_incrementEJvv:
.LFB3:
movzbl _ZN1C4flagE(%rip), %eax
cmpb $1, %al
movl _ZN1C6sharedE(%rip), %eax
sbbl $-1, %eax
movl %eax, _ZN1C6sharedE(%rip)
ret
And the 1.5 memory model should really, really prevent that (if not,
it's broken).