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

Mathias Hasselmann mathias at taschenorakel.de
Wed Sep 21 11:42:41 CEST 2016



Am 21.09.2016 um 09:52 schrieb Marc Mutz:
> On Wednesday 21 September 2016 09:23:35 Mathias Hasselmann wrote:
>> Maybe some clever use of type traits can tell us if your structs contain
>> alignment wholes?
>
> -Werror=padded :)
>

Yes, but how is it supposed to help? Let me show a real world example:

	struct Sensor
	{
	    enum Config { NotInitialized, PullUp, PullDown, Analog };

	    Config config;
	    QVariant value; //[1]
	}

No matter what order I use for config and value, the compiler will pad 
and -Wpadded will complain. How am I supposed to fix this? This 
solutions that come to my mind all are ugly, but most likely I am just 
stupid.

[1] Yes, the use of QVariant in this case is questionable,
     but that's not the point.

Ciao,
Mathias




More information about the Development mailing list