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.
@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
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