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

QString::compare yields different results for null or empty string

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.10.0
    • Fix Version/s: 5.10.1
    • Labels:
      None
    • Environment:
      Qt 5.10.0, Win32
    • Commits:
      ea6675374fa6e94bd4cf10613c85cee2c724bcdc

      Description

      We discovered that QString::compare handles null and empty strings differently:

          QString nullString;
          QString otherData("Some text");
          int nResult1 = nullString.compare(otherData, Qt::CaseInsensitive);
          QString emptyString("");
          int nResult2 = emptyString.compare(otherData, Qt::CaseInsensitive);
      

      With Qt 5.10 nResult1 equals 9 and nResult2 equals -1. In previous versions, e.g. 5.7, both results were equal -1;

        Attachments

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

          Activity

            People

            Assignee:
            thiago Thiago Macieira
            Reporter:
            phbaer Philipp Baer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes