[Development] What's our policy on changing the result of qHash(T, 0) between major releases?

Marc Mutz marc.mutz at qt.io
Wed Feb 7 06:59:24 CET 2024


On 05.02.24 19:07, apoenitz wrote:
> On Mon, Feb 05, 2024 at 09:36:39AM +0000, Marc Mutz via Development wrote:
>> Hi,
>>
>> I've always understood it such that we as Qt must preserve the property
>> that the hash for equal elements is equal within _one_ run of _one_
>> process.
> 
> This would make debugging and testing of applications using QHash
> less deterministic.
> 
> There needs to ba some way to guarantee identical behavior of multiple runs
> of the same binary. Setting the seed to 0 is currently such a way


You're right, my comment was overly simplistic. The non-determinism 
should be in the seed, and nowhere else. So developers should be able to 
rely on hash functions yielding the same value if the same seed is given 
_and the same Qt version is used_. That doesn't mean that applications 
or developers can rely on seed = 0 yielding the same hash value across 
Qt releases (even patch ones).

The end result is the same, though: we can
- definitely change exported qHash() functions
- definitely _not_ change inline qHash() functions
- possibly _not_ change any other qHash() function
   (there shouldn't be any in this category, but historically,
   there were some).

Hope that clears it up.

Thanks,
Marc

-- 
Marc Mutz <marc.mutz at qt.io>
Principal Software Engineer

The Qt Company
Erich-Thilo-Str. 10 12489
Berlin, Germany
www.qt.io

Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht Charlottenburg,
HRB 144331 B



More information about the Development mailing list