-
-
Notifications
You must be signed in to change notification settings - Fork 420
Conversation
Thanks for your pull request and interest in making D better, @rymrg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + druntime#3342" |
Thanks! Please target stable (=> v2.095.1) and add some unittests (for both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a test to validate the change.
I've added the tests. I'm not familiar with git and github. How do I push this change to both stable and master? |
The D release process is as follows:
You don't. You only need to make sure that your pull request gets merged into To allow your PRs to be merged to stable you need to:
Rebasing a branch from
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created an issue on Bugzilla so this bugfix can be included automatically in the changelog. Please update the commit message to:
Fix issue 21578 - core.atomic.atomicFetchSub for pointers incorrectly calls wrong function from core.internal.atomic
For more info, check: https://github.com/dlang/dlang-bot#automated-references
@betterC pure nothrow @nogc unittest{ | ||
shared byte* sptr = cast(byte*) 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@betterC pure nothrow @nogc unittest{ | |
shared byte* sptr = cast(byte*) 8; | |
@betterC pure nothrow @nogc unittest | |
{ | |
shared byte* sptr = cast(byte*) 8; |
assert(atomicFetchAdd(sptr, 1) == cast(shared byte*) 8); | ||
assert(atomicFetchAdd(ptr, 1) == cast(byte*) 9); | ||
assert(sptr == cast(shared byte*)9); | ||
assert(ptr == cast(byte*)10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add a test for pointers to non single byte objects. You can do it without using casts like this:
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]);
assert(*prevPtr == 2);
assert(*ptr == 8);
}
{
shared ulong* ptr = &array[5];
shared(ulong)* prevPtr = atomicFetchSub(ptr, 4);
assert(prevPtr == &array[5]);
assert(*prevPtr == 12);
assert(*ptr == 4); // https://issues.dlang.org/show_bug.cgi?id=21578
}
even on dmd there was a little copy/paste error where atomicFetchAdd was calling atomicFetchSub... Has been fixed in dlang/druntime#3342 but that is very recent.
No description provided.