Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-30148

Incorrect Clazy warning "Call to temporary is a no-op"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • Qt Creator 11.0.3
    • None
    • Apple Silicon (M1); MacOS 13.4.1; Qt Creator 11.0.3
    • macOS

    Description

      I have class JsonParser:

      class JsonParser : public QObject
      {
          Q_OBJECT
      protected:
          QJsonDocument _document;
      };
      

      In my subclass JsonSpecialistParser : public JsonParser, I have methods of the form

      void JsonSpecialistParser::task()
      {
          QJsonObject newRoot;
          //...
          _document.setObject(newRoot);
      }
      

       

       The line containing _document.setObject(newRoot) gets the Clazy warning:

      Call to temporary is a no-op: QJsonDocument::setObject [clazy-writing-to-temporary]
      

      I believe this is incorrect as _document is not a temporary and setObject operates on it directly.

      Attachments

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

        Activity

          People

            kandeler Christian Kandeler
            paulmasri Paul
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes