On Monday 31 August 2009 12:45:05 Marc Mutz wrote:
> Hi,
>
> In 4.6, you've added a QVariant ctor taking float. While I agree that not
> supporting all basic types directly in QVariant has been a flawlet of the
> class for a long time already, I would like to point out that adding this
> overload is source incompatible (though it's binary compatible):
>
> int main() {
>     const QVariant v = 1.0f;
>     return v.type() == QVariant::Double;
> };
>
> This program works when compiled against 4.5 but fails at runtime when
> compiled against 4.6. That's not really source incompatibility, I guess you
> could call it behavioural incompatibility.

We are aware of that.
This will be documented as a behavior change.

> The second example is pure source incompatibility, though:
>
> int main() {
>   const long double d = 1.0;
>   const QVariant v = d; // 4.6 error: ambiguous QVariant(float or double)?
>   return 0;
> }
>
> The addition of a float overload turned QVariant(long double) into an
> ambiguous call.
> One valid reaction is that you don't care about such corner cases. I would
> tend to agree about the first example, the author should have been explicit
> about what he's stuffing into the QVariant if he's expecting an exact type
> at the other end (as opposed to using canConvert(QVariant::Double), which I
> assume works with a float).
>
> However, you should probably fix the second example by adding a long double
> overload, and QVariant::LongDouble.

We will think about this.
Thanks for the feedback.

_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to