[Development] Should QVariant be doing fuzzy comparisons on doubles?

Mathias Hasselmann mathias at taschenorakel.de
Tue Sep 20 12:21:11 CEST 2016



Am 19.09.2016 um 23:27 schrieb Olivier Goffart:
> We really cannot have a qHash for QVariant anyway, because that would imply
> that ALL QVariant can be hashed, and compared. Which is not the case. Most
> custom types don't even register comparator function.

Which actually is quite a serious issue, as we do a simply memcmp() on 
such custom types, which simply won't work if your custom data structure 
contains uninitialized memory from alignment padding.

It is easy to forget registering comparator functions and currently Qt 
doesn't help in debugging such issues. So I wonder if QVariant should 
forbid comparison of custom types without having a comparator function 
registered.

Ciao,
Mathias



More information about the Development mailing list