Reported by Static Analyzer Tool:
Dereference null return value
Inside "ExprConstant.cpp" file, in <unnamed>::RecordExprEvaluator::VisitCXXStdInitializerListExpr(clang::CXXStdInitializerListExpr const *): Return value of function which returns null is dereferenced without checking.
bool RecordExprEvaluator::VisitCXXStdInitializerListExpr( const CXXStdInitializerListExpr *E) { // returned_null: getAsConstantArrayType returns nullptr (checked 81 out of 93 times). //var_assigned: Assigning: ArrayType = nullptr return value from getAsConstantArrayType. const ConstantArrayType *ArrayType = Info.Ctx.getAsConstantArrayType(E->getSubExpr()->getType()); LValue Array; //Condition !EvaluateLValue(E->getSubExpr(), Array, this->Info, false), taking false branch. if (!EvaluateLValue(E->getSubExpr(), Array, Info)) return false; // Get a pointer to the first element of the array. //Dereference null return value (NULL_RETURNS) //dereference: Dereferencing a pointer that might be nullptr ArrayType when calling addArray. Array.addArray(Info, E, ArrayType);
This patch adds an assert.
I think this ends up being a regression if the LValue doesn't evaluate right. This should probably go down near 10179.