-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Originally reported in https://users.rust-lang.org/t/broken-atomics-puzzle/9533
Consider this code
use std::sync::atomic::{AtomicBool, Ordering};
pub const A: AtomicBool = AtomicBool::new(false);
fn main() {
A.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst);
println!("A = {}", A.load(Ordering::SeqCst));
}
It compiles and runs cleanly, but produces unexpected results because const
is used instead of static
.
It would be nice to somehow give a warning for .compare_and_swap
call, but I am not sure it is possible.
richard-uk1, didibear, dgiger42, kaleidawave, bryanhitc and 14 more
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.