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

Olivier Goffart olivier at woboq.com
Tue Sep 20 12:44:04 CEST 2016


On Dienstag, 20. September 2016 12:21:11 CEST Mathias Hasselmann wrote:
> 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.

We don't do that. We just return false in that case.


> 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.

That's a source incompatible change.

-- 
Olivier

Woboq - Qt services and support - https://woboq.com - https://code.woboq.org



More information about the Development mailing list