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

Commonly used | 0 notation to round values to integers crashes with Qt 5.4 V4VM

    XMLWordPrintable

Details

    • 7ee29f69918ef11b83f7ee6acc1fa9c508c9f4a3

    Description

      Using the new Qt 5.4. This issue doesn't happen in Qt 5.3.2 (or Qt5.4.0-2014-11-26_11-10).

      Javascript code that retrieves the integer part of a floating point by bitwise ORing with 0 gives this assertion:
      “ASSERT: “casted->type == SInt32Type” in file compiler\qv4ssa.cpp, line 4065”

      Example code:
      QJSEngine engine;
      QString jsCode = "var n = 0.1; var test = (n*255) | 0;";
      QJSValue result = engine.evaluate( jsCode );

      Also the ~~ notation crashes.

      1. This assertion only happens when there is a variable or function call involved. That is, the assertion does not happen if the operation is only with constants like: var test = (0.1 * 255) | 0;
      2. This assertion also only happens when ORing with 0. If I change code to OR with 1, assertion does not occur.

      This notation is very common e.g. three.js rendering library uses it in many places in the code and three.js doesn't now run on top of Qt 5.4 that includes QtCanvas3D that in theory should run it.

      (from http://qt-project.org/forums/viewthread/50831/)

      Attachments

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

        Activity

          People

            erikv Erik Verbruggen
            pakerane Pasi Keränen
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes