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

Wrong string comparison

    XMLWordPrintable

Details

    • 64714ea431f2fd355ed27edc69dba4e992511e75

    Description

      Code example:

      console.log('"240000000000" == "3776798720"', "240000000000" == "3776798720");
      console.log('"240000000000" === "3776798720"', "240000000000" === "3776798720");
      console.log('"240000000000" === "3776798721"', "240000000000" === "3776798721");
      

      Output:

      qml: "240000000000" == "3776798720" true
      qml: "240000000000" === "3776798720" true
      qml: "240000000000" === "3776798721" false
      

      It looks like string interpreted as (u)int32 and high byte lost:

      240000000000 == 0x37E11D6000
      3776798720   ==   0xE11D6000
      

      This bug also effects on objects:

      var g = {};
      var h = "240000000000";
      g[h] = h + "BUG";
      console.log(JSON.stringify(g, null, 2));
      console.log(g["3776798720"], g["240000000000"]);
      

      Output:

      qml: {
        "3776798720": "240000000000BUG"
      }
      qml: 240000000000BUG 240000000000BUG
      

      As you can see the key is damaged. The value can be obtained by two different strings.

      Attachments

        Issue Links

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

          Activity

            People

              peppe Giuseppe D'Angelo
              ilyatk Ilya Tkachenko
              Votes:
              10 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes