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

QtQuick compiler generates bad code for "!=" operator

    XMLWordPrintable

Details

    • macOS
    • db6459665c (qt/qtdeclarative/dev) 9bbbd0cb21 (qt/qtdeclarative/6.3) 9bbbd0cb21 (qt/tqtc-qtdeclarative/6.3) db6459665c (qt/tqtc-qtdeclarative/dev) 48eaf1fce1 (qt/tqtc-qmlcompilerplus/6.2)

    Description

      This trivial example generates wrong C++ code:

      import QtQuick
      
      Window {
        id: root
      
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
      
        property int someValue: 42 // with 1 this would work (because !0 == 1)
      
        function foo() {
      //    console.log("bla"); // if this is active, QQC will skip this, so everything works
          if (someValue != 0) {
            t.text = "Bar";
          }
        }
      
        Text {
          id: t
          text: "Foo"
      
          TapHandler {
            onTapped: {
              console.log("Tapped")
              root.foo()
            }
          }
        }
      }
      

      Generated Code (+ clang warning):

      // generate_CmpNeInt
      r2_3 = !0 == r2;
      {
      }
      
      warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
      r2_3 = !0 == r2;
      

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            njeisecke Nils Jeisecke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes