Issue 140240
Summary false positives of bugprone-sizeof-_expression_ with a plain template type argument
Labels clang-tidy, false-positive
Assignees
Reporter sfc-gh-sgiesecke
    When a template like
```
template <typename T>
void unalignedStore(void* const dst, const T& src) noexcept {
  std::memcpy(dst, &src, sizeof(T));
}
```
is instantiated with `Foo*` such that `Foo` is an aggregate, then this produces a diagnostic of `bugprone-sizeof-_expression_`:
```
error: suspicious usage of 'sizeof(A*)' on pointer-to-aggregate type; did you mean 'sizeof(A)'?
```

I'd say that it generally makes sense to emit a warning if the sizeof _expression_ is of the form  `sizeof(T)` where `T` is a template type argument.

In addition, even if it makes sense, the diagnostic is not too helpful, as it doesn't mention the context of instantiation or the actual template type argument. `A*/A` is just a placeholder, which is generally confusing.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to