https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414

            Bug ID: 61414
           Summary: enum class bitfield size-checking failure
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tromey at gcc dot gnu.org

Consider this source:

enum class K : unsigned int {
  V = 27
};

struct S {
  K v : 5;
};

When I compile this with Fedora 20 g++ (4.8.2-based) I get:

barimba. g++ --syntax-only -pedantic -std=c++11 /tmp/q.cc
/tmp/q.cc:6:9: warning: ‘S::v’ is too small to hold all values of ‘enum class
K’ [enabled by default]
   K v : 5;
         ^

However, 5 bits is sufficient to hold all the values of K.
The warning goes away if I increase the size to 32, though of
course that defeats the purpose.

Reply via email to