[PATCH] D71001: [Clang-Tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 4 07:39:56 PST 2019


gribozavr2 added a comment.

In D71001#1768963 <https://reviews.llvm.org/D71001#1768963>, @baloghadamsoftware wrote:

> In D71001#1768880 <https://reviews.llvm.org/D71001#1768880>, @gribozavr2 wrote:
>
> > Is this a common problem? There's a lot of silly code we could try to find, but if people don't actually write it, then we get all downsides of maintenance without the benefits of the checker.
>
>
> Oh yes, all our checkers are developed upon user request. They only request it if they find out their developers write such silly code.


But how often is it? Is it just one case?

> And this kind of bug is nasty to debug. (In case of addition less memory is available behind the pointer while the memory ahead of it is lost. In case of subtraction data before the pointer gets overwritten.)

ASan can help debug this issue, and more.

This check is quite limited. For example, if the addition is done in a separate statement, this check wouldn't catch the problem. ASan would.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D71001





More information about the cfe-commits mailing list