Skip to content

transpile: Consider volatile reads a side effect - #1978

Open
Rua wants to merge 4 commits into
immunant:masterfrom
Rua:volatile-read-side-effect
Open

transpile: Consider volatile reads a side effect#1978
Rua wants to merge 4 commits into
immunant:masterfrom
Rua:volatile-read-side-effect

Conversation

@Rua

@Rua Rua commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Fixes the issue noted in #1975 (comment), that volatile reads with unused results are omitted when they shouldn't be.

@Rua
Rua force-pushed the volatile-read-side-effect branch 4 times, most recently from d26719b to 8cd218b Compare August 20, 2026 14:53
@Rua
Rua marked this pull request as ready for review August 20, 2026 14:58
@Rua
Rua force-pushed the volatile-read-side-effect branch 3 times, most recently from 62b90e1 to 476a77c Compare August 23, 2026 13:09
@fw-immunant
fw-immunant requested a review from ahomescu August 25, 2026 14:36
let mut y: bar = bar {
x: x as ::core::ffi::c_int,
} as bar;
let mut y: bar = bar { x: x };

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.

Are these side effects of the new code, or something that was there before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's from using make_cast for LValueToRValue casts. Those casts were unnecessary, but were emitted because the CTypeIds were being compared rather than the CTypeKinds.

// https://github.com/immunant/c2rust/issues/1237
--(volatile_global_struct.p);

// Unused reads, should be included as side effects.

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.

Add a case for volatile struct member reads?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@Rua
Rua force-pushed the volatile-read-side-effect branch from 476a77c to fe9ed9f Compare August 26, 2026 08:50
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.

2 participants