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

Fix reinterpret<T> for 64-bit types #6127

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

juliusikkala
Copy link
Contributor

Fixes the upper 32 bits of 64-bit values in AnyValue packing. The low 32 bits were repeated in the high bits. This caused reinterpret<T> to behave incorrectly for basic 64-bit types.

An example of the issue:

export __extern_cpp int main()
{
    int64_t ptr = 0x0123456789ABCDEF;
    uint64_t ptr2 = reinterpret<uint64_t>(ptr);
    printf("%lX\n", ptr);
    printf("%lX\n", ptr2);
    return 0;
}

prints:

123456789ABCDEF
89ABCDEF89ABCDEF

This also affects pointers, so reinterpreting addresses broke them.

@juliusikkala juliusikkala requested a review from a team as a code owner January 18, 2025 16:17
Copy link
Collaborator

@csyonghe csyonghe left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@csyonghe csyonghe added the pr: non-breaking PRs without breaking changes label Jan 18, 2025
@csyonghe csyonghe merged commit f3d7aa6 into shader-slang:master Jan 18, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants