[PATCH] D54941: [clang-tidy] Ignore bool -> single bit bitfield conversion in readability-implicit-bool-conversion

Malcolm Parsons via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 27 06:44:16 PST 2018


malcolm.parsons marked an inline comment as done.
malcolm.parsons added inline comments.


================
Comment at: docs/clang-tidy/checks/readability-implicit-bool-conversion.rst:77-78
 
-- boolean expression/literal to integer,
+- boolean expression/literal to integer (conversion from boolean to a single
+  bit bitfield is explicitly allowed),
 
----------------
aaron.ballman wrote:
> I think it should only be allowed if the bit-field type is unsigned; signed bit-fields with a single bit are inherently not portable because you don't know if that bit represents a sign bit or a value bit (imagine a sign and magnitude integer representation).
> 
> C++20 is changing this by standardizing on two's complement, but earlier versions of C++ (and currently, all versions of C) are still impacted, so another approach is to gate this on the language standard mode that's in effect.
I think it's the responsibility of a compiler using sign and magnitude representation to warn about signed single bit bitfields.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54941





More information about the cfe-commits mailing list