as i just happened to have me mutilated, i couldn't resist (even though the example 'works' only with DMD-m64 bullets):

being forced to share your foot among parallel universes, it will surely find a stray bullet in one of them.


can you guess which toe is going to be blown off?

'''
version(DigitalMars)version(D_LP64){
        import std.stdio        : writeln;
        import core.atomic      : atomicOp;

        ulong toe0 = 2;
        shared ulong toe1 = 2;
        shared ulong toe2 = 2;
        shared ulong toe3 = 2;
        uint bullet1 = 1;
        int bullet2 = 1;
        ulong bullet3 = 1;

        toe0 -= 1;
        writeln( "toe0: ", toe0 );

        atomicOp!"-="( toe1, bullet1 );
        writeln( "toe1: ", toe1 );
        
        atomicOp!"-="( toe2, bullet2 );
        writeln( "toe2: ", toe2 );

        atomicOp!"-="( toe3, bullet3 );
        writeln( "toe3: ", toe3 );
}


( https://issues.dlang.org/show_bug.cgi?id=16651 )

Reply via email to