[PATCH] D111655: [analyzer] non-obvious analyzer warning: Use of zero-allocated memory

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 12 10:11:46 PDT 2021


Quuxplusone added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2474-2475
     auto R = std::make_unique<PathSensitiveBugReport>(
-        *BT_UseZerroAllocated[*CheckKind], "Use of zero-allocated memory", N);
+        *BT_UseZerroAllocated[*CheckKind],
+        "Use of memory allocated with size zero", N);
 
----------------
Peanut gallery says:
(1) Might want to fix the typo in "Zerro" at the same time, or in a followup commit.
(2) I would naively have expected all the test cases below to give something simple like "Read/write beyond end of allocated space," because they allocate N bytes and then try to read/write into byte number N. This is //never// allowed in C or C++, regardless of the value of N; there's nothing special about N=0. So I don't see why it needs //any// special diagnostic (confusing or otherwise).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111655/new/

https://reviews.llvm.org/D111655



More information about the cfe-commits mailing list