Skip to content

Support for initialized atomics and __c11_atomic_signal_fence - #2006

Draft
brk wants to merge 2 commits into
immunant:masterfrom
brk:atomic-nits
Draft

Support for initialized atomics and __c11_atomic_signal_fence#2006
brk wants to merge 2 commits into
immunant:masterfrom
brk:atomic-nits

Conversation

@brk

@brk brk commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #1667.

AI disclosure: this code was written by Codex.

@ahomescu

Copy link
Copy Markdown
Contributor

I think this is already covered by #2001.

} else if let &CTypeKind::IncompleteArray(_) = resolved_ty {
// Incomplete arrays are translated to zero length arrays
Ok(WithStmts::new_val(mk().array_expr(vec![])))
} else if let &CTypeKind::Atomic(ty) = resolved_ty {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is also in #2001.

// compile time, so we only support a constant one. A relaxed fence
// is a no-op (and Rust has no relaxed fence intrinsic), so we drop it.
"__atomic_thread_fence" | "__atomic_signal_fence" => {
"__atomic_thread_fence" | "__atomic_signal_fence" | "__c11_atomic_signal_fence" => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this in the other PR, I think we keep it.

@thedataking

Copy link
Copy Markdown
Contributor

Thanks @brk; #2001 landed, please rebase so we can land this PR next.

@brk
brk marked this pull request as draft September 10, 2026 12:06
@brk

brk commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

web merge on github looks like it will duplicate the Atomic initializer clause, will fix by hand in a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C2Rust fails on C11 atomic initialization: Unsupported default initializer: Atomic(...) for ATOMIC_VAR_INIT

3 participants