Skip to content

Mind alignment #3

@bluss

Description

@bluss

The code in number_streams is cool, but from a cursory look it seems to cast a u8 pointer directly to a u64 pointer, which is not correct in general.

This depends on the platform / architecture, some tolerate loading from ill aligned addresses fine and some don't. x86-64 is generally fine, and why we don't see much trouble, but on other platforms you will.

This blog mentions using memcpy to let the compiler decide how to load from a possibly ill aligned address. This is what google's farmhash does too, and it's also what I updated SipHash to do, see rust-lang/rust#27280.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions