| Re: Compiler ordering barriers in C++0x |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.c++.moderated · Group Profile
Author: Chris ThomassonChris Thomasson Date: May 4, 2008 15:20
> I can prove that I have happens-before relation if I can enforce
> correct compiler ordering. Consider following code:
>
> std::vector g_nonatomic_user_data;
> std::atomic_int g_atomic1;
> std::atomic_int g_atomic2;
>
> std::vector thread()
> {
> g_atomic1.store(1, std::memory_order_relaxed);
> // compiler store-load fence
> if (g_atomic2.load(std::memory_order_relaxed))
[...]
Are you sure that atomic store with 'memory_order_relaxed' semantics injects
a #StoreLoad after the operation?
|