This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61414] New: enum class bitfield size-checking failure
- From: "tromey at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 04 Jun 2014 17:30:28 +0000
- Subject: [Bug c++/61414] New: enum class bitfield size-checking failure
- Auto-submitted: auto-generated
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.