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.

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.

Here's a summary of compatibility issues surrounding adding overloads:

1. Overloading a non-ctor function that wasn't overloaded before is SIC
   (&func, &Class::func are now ambiguous)
2. Overloading a function may necessitate adding further overloads to keep
   unwanted ambiguities in check:
   void f(double);
 + void f(float);
 -> f((long double)1.0) is now ambiguous

Thanks,
Marc

-- 
Marc Mutz <[email protected]> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to