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

QVarLengthArray(std::initializer_list<T>) ctor asserts on pathcc

    XMLWordPrintable

Details

    • b0c321a8db7b75d740d968c6a583473600faf990

    Description

      While attempting to build Qt with PathScale pathcc compiler, I've noticed that VarLengthArray tests fail:

      QFATAL : tst_QVarLengthArray::initializeListInt() ASSERT: "abuf" in file ../../../../../include/QtCore/../../src/corelib/tools/qvarlengtharray.h, line 305
      FAIL!  : tst_QVarLengthArray::initializeListInt() Received a fatal error.
         Loc: [Unknown file(0)]
      

      After some debugging, I've figured out that it fails because QVarLengthArray(std::initializer_list<T> args) ctor calls:

              append(args.begin(), args.size());
      

      In pathcc, when args.size() == 0, args.begin() is nullptr. However, the append() method unconditionally asserts on the first parameter being non-null.

      From http://en.cppreference.com/w/cpp/utility/initializer_list/begin:

      If the initializer list is empty, the values of begin() and end() are unspecified, but will be identical.

      Therefore, there is no reason why they couldn't be null in this case.

      Please either add an additional check for args.size() being non-zero before calling append() in the initializer list ctor, or just move the assertion in append() method below increment check.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            mgorny Michał Górny
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes