transpile: Conservatively disallow mutable lvalues inside macros - #1989
Open
Rua wants to merge 4 commits into
Open
transpile: Conservatively disallow mutable lvalues inside macros#1989Rua wants to merge 4 commits into
Rua wants to merge 4 commits into
Conversation
Rua
force-pushed
the
addrof-complit-macro
branch
3 times, most recently
from
September 2, 2026 11:24
ec84503 to
cba7496
Compare
Rua
marked this pull request as draft
September 2, 2026 16:47
Rua
force-pushed
the
addrof-complit-macro
branch
3 times, most recently
from
September 3, 2026 16:47
93cd11c to
7612f6c
Compare
Rua
force-pushed
the
addrof-complit-macro
branch
from
September 3, 2026 17:05
7612f6c to
848ff3e
Compare
Rua
marked this pull request as ready for review
September 3, 2026 18:21
Rua
force-pushed
the
addrof-complit-macro
branch
2 times, most recently
from
September 7, 2026 16:53
9c364c6 to
79b04c9
Compare
Rua
force-pushed
the
addrof-complit-macro
branch
from
September 7, 2026 16:55
79b04c9 to
c3bf0bb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
macros.csnapshot test #1993Mutable lvalues are values that can either be assigned to, or have a mutable pointer created to them. If they are in a macro, that could pose problems. DeclRefs (including those to mutable variables) are already disallowed in macros, but another "out of nothing" source of mutable lvalues is compound literals. Currently, a macro containing a mutable compound literal is translated as-is, including something like this:
Each mutable compound literal expression is supposed to create its own distinct memory location (immutable ones are allowed to be coalesced). So these pointers must be different, and their pointees must be able to be modified independently.
I've been very conservative here and disallowed all mutable lvalues in macros. There are certainly instances that could be re-allowed on a case-by-case basis. Certain instances of lvalues that undergo an
LValueToRValuecast for example.