This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/61414] New: enum class bitfield size-checking failure


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]