Reported by Coverity:
Inside "CGExpr.cpp" file, in clang::CodeGen::CodeGenFunction::EmitOMPArraySectionExpr(clang::OMPArraySectionExpr const *, bool): Return value of function which returns null is dereferenced without checking.
} else { //returned_null: getAsConstantArrayType returns nullptr (checked 83 out of 95 times). // var_assigned: Assigning: CAT = nullptr return value from getAsConstantArrayType. auto *CAT = C.getAsConstantArrayType(ArrayTy); //identity_transfer: Member function call CAT->getSize() returns an offset off CAT (this). // Dereference null return value (NULL_RETURNS) //dereference: Dereferencing a pointer that might be nullptr CAT->getSize() when calling APInt. ConstLength = CAT->getSize(); }
This patch adds an assert to resolve the bug.