[PATCH] D114427: [clang-tidy] Warn on functional C-style casts

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 27 19:20:07 PST 2021


Quuxplusone added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.cpp:342
+  auto w = new int(x);
+}
----------------
What about
```
template<class T> T foo(int i) { return T(i); }
int main() {
    foo<std::vector<int>>(); // valid, OK(!)
    foo<double>(); // valid, not OK
}
```
What about
```
struct Widget { Widget(int); };
using T = Widget;
using U = Widget&;
int i = 42;
Widget t = T(i);  // valid, OK?
Widget u = U(i);  // valid C++, should definitely not be OK
```
https://quuxplusone.github.io/blog/2020/01/22/expression-list-in-functional-cast/


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

https://reviews.llvm.org/D114427



More information about the cfe-commits mailing list