Closed tekezo closed 5 years ago
I confirmed the latest revision fixed this issue. Thank you!
@tekezo Thanks for letting me know.
As @siffiejoe notes, std::hash<nonstd::variant>
may well include padding bits in a variant alternative structure for the computation of the hash value. This can have a randomizing effect on the hash value.
The solution seems to be to require std::hash<userdefined-struct>
to be available and use that.
Thanks @tekezo & s @siffiejoe.
There is a problem that
std::hash<nonstd::variant>
does not return the same hash value for the same variant value.Version
Both variant-lite@1051f91afd28fdfc05b2d2b8d1a0359090aabe3e and v1.1.0.
Example code
Actual result
(v1 != v2)
Expected result
(v1 == v2)
Note
I guess the
hash
is accessing uninitialized memory here.https://github.com/martinmoene/variant-lite/blob/master/include/nonstd/variant.hpp#L832