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

Codegen: fix how unions are represented to not miss bytes #12551

Merged
merged 2 commits into from
Oct 4, 2022

Conversation

asterite
Copy link
Member

@asterite asterite commented Oct 1, 2022

Fixes #12550

I'm actually not sure if this is the correct solution, but... all the snippets in that issue now work fine.

See the comments in the commit for an explanation of what's done here.

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:codegen labels Oct 1, 2022
@asterite
Copy link
Member Author

asterite commented Oct 1, 2022

An alternative solution, which is apparently what clang does, is to keep the union representation we had before, but whenever a union is moved we cast that union to the representation used by this PR (or a similar one) to move the bytes, so all the bytes are moved.

Maybe there is a downside of representing the union like this instead of only when passing it around?

That said, everything seems to be working better with this PR, so it's an improvement.

Oh, I realized I didn't include a test... if someone wants to include it, please do so. Otherwise I might do it next week.

@straight-shoota straight-shoota added this to the 1.6.0 milestone Oct 3, 2022
@straight-shoota straight-shoota merged commit 43f0a64 into master Oct 4, 2022
@straight-shoota straight-shoota deleted the bug/union-representation branch October 4, 2022 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:codegen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C unions of structs with different sizes are corrupted while passed to Crystal
2 participants