Unexpected behaviour of const atomics
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=139b1c685d63e315c4e7140bcfc6694f
use std::sync::atomic::{AtomicBool, Ordering};
fn main() {
const ATOMIC_BOOL: AtomicBool = AtomicBool::new(true);
ATOMIC_BOOL.store(false, Ordering::SeqCst);
eprintln!("ATOMIC_BOOL == {}", ATOMIC_BOOL.load(Ordering::SeqCst));
}
I expected to see this happen:
Either fail to compile, or compile with warning, or print ATOMIC_BOOL == false
Instead, this happened:
Compiled without any warnings, output is ATOMIC_BOOL == false, which is unexpected.
Meta
rustc --version --verbose:
rustc 1.89.0 (29483883e 2025-08-04) (Fedora 1.89.0-2.fc42)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.8
P.S. There is a Clippy lint about this, but I believe that it should be a rustc warning instead.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Rust Playground snippet and compare rustc’s behavior with the Clippy lint mentioned in the report. No repository file or test is named, so trace the compiler handling of const AtomicBool mutation and determine whether the intended outcome is a rustc warning; done means the reported behavior has an agreed diagnostic or documented resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100