You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix invalid pointer casts in arm64 implementation (#65)
* Fix invalid pointer casts in arm64 implementation
It is UB in C and C++ to type-pun pointers in this way, for two reasons.
First, casting to a pointer is forbidden if the pointer is not aligned.
Second, this kind of type-punning is a strict aliasing violation.
Instead, the way to read 8 bytes as a time as a uint64_t is to call
memcpy. Compilers recognize this pattern and optimize it, lowering it to
the same code, but without breaking the language's abstract state
machine.
This is needed to fix some UBSan warnings in Chromium.
* Use crc32c_read_le.h instead
In doing so, I fixed up crc32c_read_le.h a bit:
1. The documentation and tests say the buffers need to be aligned, but
they don't.
2. Add a 16-bit version.
3. Remove an unnecessary static_cast<uint8_t>. The pointer is already
uint8_t.
4. Replace the necessary static_casts with uintN_t{x} per the Google
style guide. https://google.github.io/styleguide/cppguide.html#Casting
0 commit comments