Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-127759

Qt::partial_ordering::unordered implements op!=() incorrectly

    XMLWordPrintable

Details

    • 3
    • fed1099ad (dev), d39441a2e (dev), 247ec89cc (6.8), a83d113f6 (6.8), f1cc1f13d (6.7), 82e23d266 (6.7), b40f9b8c3 (tqtc/lts-6.5), a76ed16a8 (tqtc/lts-6.5), 0718845d3 (tqtc/lts-6.2), ff8fecc4b (tqtc/lts-6.2)
    • Foundation Sprint 113, Foundation Sprint 114

    Description

      The inequality operator in Qt::partial_ordering (or QPartialOrdering in earlier versions) is implemented as follows:

      friend constexpr bool operator!=(partial_ordering lhs,
                                       QtPrivate::CompareAgainstLiteralZero)
          noexcept
      { return lhs.isOrdered() && lhs.m_order != 0; }
      

      This operator incorrectly demands that the lhs value is ordered. However, unordered values are always not-equal to any other values, so we can skip the isOrdered() check here.

      The test would be:

      float nan = std::numeric_limits<float>::quiet_NaN();
      const auto r = Qt::compareThreeWay(nan, 1.f);
      QVERIFY(r != 0); // FAILS now
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ivan.solovev Ivan Solovev
            ivan.solovev Ivan Solovev
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: