Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.6.2, 5.7.0
-
None
-
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.