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

GCC/Clang differences on QJsonValue initialization

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 6.4.2
    • Core: Serialization
    • None
    • Linux/X11

    Description

      Sample/Pseudo code;

       

      QJsonObject m_obj;
      void updateJson(const QJsonValue &val) {m_obj["key"] = val;}
      
      void set1(const QStringList &val) {
          updateJson(QJsonArray::fromStringList(val));
      }
      
      void set2(const QStringList &val) {
          QJsonArray tObj = QJsonArray::fromStringList(val);
          updateJson(tObj);
      }
      
      QStringList get() const {
          return m_obj["key"].toVariant().toStringList();
      }
      
      main (){
        set1({"testing"});
        qDebug() << get();
        // CLANG: QVariant(QVariantList, QList(QVariant(QString, "testing")))
        // GCC: QVariant(QVariantList, QList(QVariant(QString, "testing")))
      
        set2({"testing"});
        qDebug() << get();
        // CLANG: QVariant(QVariantList, QList(QVariant(QString, "testing")))
        // GCC: QVariant(QVariantList, QList(QVariant(QVariantList, QList(QVariant(QString, "testing")))))
      }

       

      Seems like compilers select different paths. 

      https://godbolt.org/z/WqPfhTbM4

      madwinter 

       

       

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              hancerliqt Burak Hancerli
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes