-
Notifications
You must be signed in to change notification settings - Fork 13k
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
derive(Hash)
on enum causes hash collision on 32-bit system
#21714
Comments
These APIs have changed a bunch. I think this is the situation today:
I don't have
the |
cc @ranma42 |
This can be addressed the same way as #24270. |
This seems to be fixed: http://is.gd/tm84D2 (the variants no longer have the same discriminant) |
Isn't that a 64-bit system? On Saturday, March 5, 2016, Alex Burka notifications@github.com wrote:
|
Yes, but it seems like the real bug in the original was |
I think it's that in the syntax expansion, one's hash is 1i32 and the On Saturday, March 5, 2016, Alex Burka notifications@github.com wrote:
|
@apasel422 I understand now. Working on a fix. |
This is the same approach taken in rust-lang#24270, except that this should not be a breaking change because it only changes the output of hash functions, which nobody should be relying on.
This is the same approach taken in rust-lang#24270, except that this should not be a breaking change because it only changes the output of hash functions, which nobody should be relying on.
cleanups and fixes for #[derive] This contains a bunch of little cleanups and fixes to `#[derive]`. There are more extensive comments on each individual commit. - hygiene cleanups - use `discriminant_value` instead of variant index in `#[derive(Hash)]` - ~~don't move out of borrowed content in `#[derive(PartialOrd, PartialEq)]`~~ - use `intrinsics::unreachable()` instead of `unreachable!()` I don't believe there are any breaking changes in here, but I do want some more eyes on that. Fixes rust-lang#2810 (!), I believe (we still assume that "std" or "core" is the standard library but so does the rest of rustc...). Fixes rust-lang#21714 (cc @apasel422). ~~Fixes~~ (postponed) rust-lang#24047 (cc @withoutboats @bluss). Fixes rust-lang#31714 (cc @alexcrichton @bluss). Fixes rust-lang#31886 (cc @oli-obk).
This is the same approach taken in rust-lang#24270, except that this should not be a breaking change because it only changes the output of hash functions, which nobody should be relying on.
cleanups and fixes for #[derive] This contains a bunch of little cleanups and fixes to `#[derive]`. There are more extensive comments on each individual commit. - hygiene cleanups - use `discriminant_value` instead of variant index in `#[derive(Hash)]` - ~~don't move out of borrowed content in `#[derive(PartialOrd, PartialEq)]`~~ - use `intrinsics::unreachable()` instead of `unreachable!()` I don't believe there are any breaking changes in here, but I do want some more eyes on that. Fixes #2810 (!), I believe (we still assume that "std" or "core" is the standard library but so does the rest of rustc...). Fixes #21714 (cc @apasel422). ~~Fixes~~ (postponed) #24047 (cc @withoutboats @bluss). Fixes #31714 (cc @alexcrichton @bluss). Fixes #31886 (cc @oli-obk).
This is the same approach taken in rust-lang#24270, except that this should not be a breaking change because it only changes the output of hash functions, which nobody should be relying on.
This is the same approach taken in rust-lang#24270, except that this should not be a breaking change because it only changes the output of hash functions, which nobody should be relying on.
derive: use discriminant_value in #[derive(Hash)] derive: use discriminant_value in #[derive(Hash)] Fixes #21714. Spawned from #32139. r? @alexcrichton
derive: use discriminant_value in #[derive(Hash)] derive: use discriminant_value in #[derive(Hash)] Fixes #21714. Spawned from #32139. r? @alexcrichton
derive: use discriminant_value in #[derive(Hash)] derive: use discriminant_value in #[derive(Hash)] Fixes rust-lang#21714. Spawned from rust-lang#32139. r? @alexcrichton
Output of
-Z unstable-options --pretty=expanded
is:Here
A
uses1
(isi32
) andB
uses1us
for hashing, thus they collide if they have same bit representation.(was potential issue of #18573)
The text was updated successfully, but these errors were encountered: