From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1058 invoked by alias); 19 Nov 2012 11:52:51 -0000 Received: (qmail 1014 invoked by uid 48); 19 Nov 2012 11:52:38 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/51242] [C++11] Unable to use strongly typed enums as bit fields Date: Mon, 19 Nov 2012 11:52:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg01744.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242 --- Comment #6 from Jonathan Wakely 2012-11-19 11:52:38 UTC --- The check is for an unscoped enumeration type which does seem intentional. This change allows the example to compile: --- cp/decl2.c.orig 2012-11-19 11:50:28.842443803 +0000 +++ cp/decl2.c 2012-11-19 11:46:08.445472115 +0000 @@ -1026,7 +1026,7 @@ if (TREE_CODE (value) == VOID_TYPE) return void_type_node; - if (!INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (value)) + if (!INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value)) && (POINTER_TYPE_P (value) || !dependent_type_p (TREE_TYPE (value)))) { It emits a warning though: e.cc:5:19: warning: 'MyClass::Field1' is too small to hold all values of 'enum class MyEnum' [enabled by default]