Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5, 6.6, dev
-
None
-
3
-
Foundation PM Prioritized, Foundations Sprint 97, Foundations Sprint 98, Foundations Sprint 99, Foundation Sprint 100, Foundation Sprint 101, Foundations Sprint 102, Foundation Sprint 103, Foundation Sprint 104, Foundation Sprint 105, Foundation Sprint 106
Description
As pointed out by Eddy in the comments to https://codereview.qt-project.org/c/qt/qtbase/+/481410/14, qfloat16 implements relational operators in such way, that all integral values outside of its range are equal to qfloat16's infinity.
The same problem exists for qfloat16 vs qfloat16 comparison.
This is not an expected behavior, if we compare it with built-in types. Consider the following example:
const float inf = std::numeric_limits<float>::infinity(); const float out_of_qf16_range = 13e5f; const qfloat16 qf16_inf = qfloat16(inf); Q_ASSERT(qf16_inf.isInf()); // built-in types Q_ASSERT(inf != out_of_qf16_range); // float vs float Q_ASSERT(inf != int(out_of_qf16_range)); // float vs int // qfloat16 Q_ASSERT(qf16_inf != out_of_qf16_range); // OK! Q_ASSERT(qf16_inf != int(out_of_qf16_range)); // qf16 vs int - FAIL! Q_ASSERT(qf16_inf != qfloat16(out_of_qf16_range)); // qf16 vs qf16 - FAIL!
This is discovered while working on C++20 comparison story, but this is a pre-existing problem.
Comparison with FP types works as expected.
Attachments
Issue Links
- relates to
-
QTBUG-117637 qfloat16 comparison with integral types is ambiguous
-
- Closed
-
-
QTBUG-104113 Modernize comparisons: can we provide macros?
-
- Closed
-
Gerrit Reviews
For Gerrit Dashboard: QTBUG-118193 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
523659,4 | qfloat16: fix comparisons against int | dev | qt/qtbase | Status: NEW | +1 | 0 |