[Issue 21578] core.atomic.atomicFetchSub for pointers incorrectly calls wrong function from core.internal.atomic
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jan 24 23:22:21 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21578
--- Comment #1 from ZombineDev <petar.p.kirov at gmail.com> ---
Test case:
import core.atomic;
shared(ulong)[] array = [2, 4, 6, 8, 10, 12, 14, 16, 19, 20];
{
shared ulong* ptr = &array[0];
shared(ulong)* prevPtr = atomicFetchAdd(ptr, 3);
assert(prevPtr == &array[0]); // OK
assert(*prevPtr == 2); // OK
assert(*ptr == 8); // OK
}
{
shared ulong* ptr = &array[5];
shared(ulong)* prevPtr = atomicFetchSub(ptr, 4);
assert(prevPtr == &array[5]); // OK
assert(*prevPtr == 12); // OK
assert(*ptr == 4); //fails
}
--
More information about the Digitalmars-d-bugs
mailing list