Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sema: disallow unsafe in-memory coercions #22243

Merged
merged 3 commits into from
Dec 16, 2024
Merged

Conversation

mlugg
Copy link
Member

@mlugg mlugg commented Dec 15, 2024

The error messages here aren't amazing yet, but this is an improvement on status quo, because the current behavior allows false negative compile errors, so effectively miscompiles.

Resolves: #15874

@mlugg mlugg force-pushed the better-imc branch 3 times, most recently from ba3a57b to 62825c0 Compare December 16, 2024 00:14
The error messages here aren't amazing yet, but this is an improvement
on status quo, because the current behavior allows false negative
compile errors, so effectively miscompiles.

Resolves: ziglang#15874
The previous commit exposed some missing `const` qualifiers in a few
places. These mutable slices could have been used to store invalid
values into memory!
And change corresponding signature in `DarwinPosixSpawn`.
@mlugg mlugg added the breaking Implementing this issue could cause existing code to no longer compile or have different behavior. label Dec 16, 2024
@mlugg
Copy link
Member Author

mlugg commented Dec 16, 2024

This is technically breaking, but I'm unsure if it should have release notes or not, since the breakage is fairly minor -- the most common case will just be a missing const in a nested pointer type. @andrewrk, if you think this deserves release notes, feel free to add the label and I'll write some up when I get around to it.

@mlugg mlugg merged commit 32354d1 into ziglang:master Dec 16, 2024
10 checks passed
@andrewrk
Copy link
Member

I think it's worth a note - you had to fix some pointer types in DarwinPosixSpawn.zig after all - and that might not be obvious to users without a mention it the release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior. release notes This PR should be mentioned in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid pointer casts permitted by in-memory coercion to covariant types
2 participants