-
Notifications
You must be signed in to change notification settings - Fork 57
Fix union field access by representing unions as structs #269
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
base: main
Are you sure you want to change the base?
Conversation
@simensgreen can you check this fix? |
When a union has multiple fields, represent it as a struct with all fields at offset 0 instead of just using the largest field. This allows pointer casts between union fields to work correctly by enabling the recover_access_chain_from_offset function to find valid access chains. Fixes Rust-GPU#241.
@LegNeato Ok, in this simple example it works, but in a more complicated scenario, it will not. Now I can reproduce both Full error messages:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocked by #270 due to adding a test
Ok, this code is a minefield...back to the drawingboard ha. |
When a union has multiple fields, represent it as a struct with all fields at offset 0 instead of just using the largest field. This allows pointer casts between union fields to work correctly by enabling the recover_access_chain_from_offset function to find valid access chains.
Fixes #241.