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

Prefer memcpy to cast of unaligned pointer #51

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

fosterbrereton
Copy link
Contributor

Provide an unaligned_read routine for reading integers at any memory address, not just those that are at language-prescribed alignment offsets. The solution is to use memcpy, which the compiler will optimize away as able. Fixes #49.

@fosterbrereton
Copy link
Contributor Author

UBSan test is coming back clean (though even if it didn't, it's not reporting properly as per #50)

@fosterbrereton fosterbrereton enabled auto-merge (squash) September 1, 2022 15:14
@leethomason
Copy link
Contributor

Do you mind patching up the other unaligned reads in string_pool.cpp? Then everything would be tidy and consistent.

Copy link
Contributor

@leethomason leethomason left a comment

Choose a reason for hiding this comment

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

Looks good! Nice clarification.

@fosterbrereton fosterbrereton merged commit 793639c into main Sep 6, 2022
@fosterbrereton fosterbrereton deleted the fosterbrereton/unaligned-read branch September 6, 2022 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Murmer3 implementation has UB flagged by UBSan (though probably safe on desktop)
2 participants