D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20122 - core.atomic.cas discards result on failure
Summary: core.atomic.cas discards result on failure
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2019-08-12 02:58 UTC by Manu
Modified: 2019-08-13 10:08 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Manu 2019-08-12 02:58:44 UTC
The implementation of `cas` discards the result when the compare fails.
This is a strange choice, and not desirable.

There needs to be additional overloads that actually return the result.
Comment 1 Dlang Bot 2019-08-13 07:50:56 UTC
@TurkeyMan created dlang/druntime pull request #2733 "Fixed the cas function not returning the result" fixing this issue:

- Fix Issue 20122 - core.atomic.cas discards result on failure
  
  Added overloads that return the result.

https://github.com/dlang/druntime/pull/2733
Comment 2 Dlang Bot 2019-08-13 10:08:48 UTC
dlang/druntime pull request #2733 "Fixed the cas function not returning the result" was merged into master:

- 5276bef147346a4b0adfae0eb7f7381efafb382a by Manu Evans:
  Fix Issue 20122 - core.atomic.cas discards result on failure
  
  Added overloads that return the result.

https://github.com/dlang/druntime/pull/2733