[phobos] Fwd: Re: Ruling out arbitrary cost copy construction?

David Simcha dsimcha at gmail.com
Mon Nov 1 10:49:59 PDT 2010


On Mon, Nov 1, 2010 at 1:39 PM, Michel Fortin <michel.fortin at michelf.com>wrote:

>
> Is "i++" really atomic when i is a size_t? I though it was a
> read-modify-write operation. The read might be atomic, the write might be
> atomic, but the whole isn't. And in addition to atomicity, it needs to be
> sequentially consistent unless we change the GC to keep threads frozen while
> calling the destructors.
>
>
In theory it could be read-modify-write because you never know if some
incredibly stupid compiler will do something like:

mov EAX, [someAddress];
inc EAX;
mov [someAddress], EAX;

instead of just:

inc [someAddress];

However, I'm pretty sure the second form is atomic, and even if it's not
formally guaranteed, any reasonable compiler would use the single inc
instruction form.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20101101/086bcfec/attachment.html>


More information about the phobos mailing list