1

Is there any rule which makes clang tidy to warn about useless reinterpret_cast where static_cast can be used ? E.g.

void f(void* p)
{
    int* x = reinterpret_cast<int*>(p);
    // static_cast is enough here
}
Sisir
  • 4,584
  • 4
  • 26
  • 37
NN_
  • 1,593
  • 1
  • 10
  • 26

1 Answers1

0

There is no such check in clang-tidy.

If you need this check, you'll have to write it yourself. There is a similar one that can be used as a starting point - google-readability-casting checks for C-style casts and can automatically fix them in cases static_cast is sufficient.

pablo285
  • 2,460
  • 4
  • 14
  • 38
  • What do you mean write by myself ? Change clang-tidy code ? – NN_ May 16 '19 at 17:27
  • Yes, clang-tidy is open source, you are free to write your own checks. There is even documentation available for writing checks. – pablo285 May 17 '19 at 06:43