aaron.ballman added a comment. After some more thought and some offline discussions, I think I have a reasonable way forward: let's add `-Wsingle-bit-bitfield-constant-conversion` as a new warning group under `-Wbitfield-constant-conversion` that controls the diagnostic for one-bit bitfields. The diagnostic behavior here is pedantically correct and will help catch some bugs for folks, but there's enough existing code using `1` and not misbehaving (probably because they're not inspecting the value except in a boolean context) that having separate control seems useful.
What do others think? In D131255#3725818 <https://reviews.llvm.org/D131255#3725818>, @bjope wrote: > A similar warning (when assigning -1 to an unsigned bitfield) can be given by > both gcc and clang by using ` -Wsign-conversion` but that is not part of > `-Wall` either. But maybe that is a totally different thing. It's a different thing. When the bit-field is unsigned, the conversion from signed is well-defined and so we only issue a `-Wconversion` warning, but it doesn't technically truncate the bit-field. That's also why we don't diagnose: https://godbolt.org/z/WW9477jfG Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131255/new/ https://reviews.llvm.org/D131255 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits