On Saturday, 9 January 2016 at 17:24:47 UTC, Jin wrote:
On Saturday, 9 January 2016 at 16:29:07 UTC, Ola Fosheim Grøstad wrote:
They have to be atomic if you want your code to be portable.

Do not want yet :-)

Okay I've just refreshed my mental X86/64 memory model :-) What you've done should be okay from a CPU-reordering perspective. In x86/64 Loads are not reordered with other loads and stores are not reordered with other stores. So from a CPU perspective you should be okay on X86/64.

There's still a grey area for me around possible *compiler* re-orderings... there's nothing to stop the compiler reordering those two lines with respect to each other because from an 'as-if-sequential' perspective those two operations are commutative. Unfortunately I'm not well versed enough on the internals of the three main compiler versions to give an opinion on whether this will be a problem or not :-(

If your version is working for you on your platform/compiler, I'd recommend maybe being a bit conservative and wrap your code with appropriate version blocks until you know the answer to these questions for the other platforms/compilers (ARM, GDC, LDC etc.). And put appropriate explanation why that's the case in your README.md. I think that's just a basic courtesy to other users that you don't let them walk over a minefield without fair warning :-)

Cheers,

A.













Reply via email to