[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 16 07:37:27 PDT 2016


thakis added inline comments.

================
Comment at: test/SemaCXX/warn-msvc-enum-bitfield.cpp:12
@@ +11,3 @@
+
+  s.e2 = E2;
+  s.f2 = F2;
----------------
sashab wrote:
> thakis wrote:
> > Shouldn't this be the version that warns? The assignment with E1 assigns 0 which is portable, but this assigns 1 which overflows, right?
> e2 is not a bitfield :) So this code is fine.
> 
> And we should warn on all assignments, since any assigned value could potentially be incorrect. Also, most assignments are not static so we don't always have that information :)
Do you have any data on false positive rate when we just always warn unconditionally? i.e. did you build some large-ish open-source program (clang, chromium, firefox, ...) and is the true positive / false positive rate ok? (we have some problems with "always warn" with other enum warning which we currently always have to disable, e.g. https://bugs.chromium.org/p/chromium/issues/detail?id=621097)

To land, you need to `svn commit` or ask someone with commit access to do that for you -- llvm doesn't have a commit queue.


https://reviews.llvm.org/D24289





More information about the cfe-commits mailing list