From 638cededda9082a6c43e8541c16930900de90fc3 Mon Sep 17 00:00:00 2001 From: k-hara Date: Sat, 29 Nov 2014 12:16:18 +0900 Subject: [PATCH] Supplemental fix for issue 13783 in std.parallelism `auto f(ref ubyte);` should not take an lvalue of `enum E : ubyte`. Fixing 13783 will disallow the accepts-invalid bug. --- std/parallelism.d | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/std/parallelism.d b/std/parallelism.d index c2ff1331a6f..1590c255818 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -204,20 +204,23 @@ else without wrapping it. If I didn't wrap it, casts would be required basically everywhere. */ -private void atomicSetUbyte(ref ubyte stuff, ubyte newVal) +private void atomicSetUbyte(T)(ref T stuff, T newVal) +if (__traits(isIntegral, T) && is(T : ubyte)) { //core.atomic.cas(cast(shared) &stuff, stuff, newVal); atomicStore(*(cast(shared) &stuff), newVal); } -private ubyte atomicReadUbyte(ref ubyte val) +private ubyte atomicReadUbyte(T)(ref T val) +if (__traits(isIntegral, T) && is(T : ubyte)) { return atomicLoad(*(cast(shared) &val)); } // This gets rid of the need for a lot of annoying casts in other parts of the // code, when enums are involved. -private bool atomicCasUbyte(ref ubyte stuff, ubyte testVal, ubyte newVal) +private bool atomicCasUbyte(T)(ref T stuff, T testVal, T newVal) +if (__traits(isIntegral, T) && is(T : ubyte)) { return core.atomic.cas(cast(shared) &stuff, testVal, newVal); }