Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1026,8 +1026,7 @@ ASTContext &AstContext = C.getASTContext(); CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType); - if (Optional DefinedSize = - ElementCount.getAs()) { + if (ElementCount.getAs()) { DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder); // size in Bytes = ElementCount*TypeSize SVal SizeInBytes = svalBuilder.evalBinOpNN( Index: cfe/trunk/test/Analysis/out-of-bounds-new.cpp =================================================================== --- cfe/trunk/test/Analysis/out-of-bounds-new.cpp +++ cfe/trunk/test/Analysis/out-of-bounds-new.cpp @@ -148,3 +148,9 @@ int *buf = new int[s]; buf[0] = 1; // no-warning } +//Tests complex arithmetic +//in new expression +void test_dynamic_size2(unsigned m,unsigned n){ + unsigned *U = nullptr; + U = new unsigned[m + n + 1]; +}