[PATCH] D53488: [clang-tidy] Catching narrowing from double to float.

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 5 01:12:06 PST 2018

lebedev.ri added inline comments.

Comment at: test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp:164
+  while (i) {
+    // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: narrowing conversion from 'int' to 'bool' [cppcoreguidelines-narrowing-conversions]
+  }
courbet wrote:
> What about providing a fix for this one :
> `while (i != 0) {`
Is this //actually// a narrowing conversion as per the CPPCG?
Conversion to bool is a special case, it's not a truncation, but a `x != 0`.
I'd think cases like these where bool was pretty clearly meant (`if()`, `while()`, `for()`, ???) should be exempt.

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list