From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15928 invoked by alias); 30 Jan 2013 16:29:46 -0000 Received: (qmail 15779 invoked by uid 48); 30 Jan 2013 16:29:14 -0000 From: "mib.bugzilla at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56155] New: [C++0X] enumeration with fixed underlying type - enum literals have wrong type Date: Wed, 30 Jan 2013 16:29:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mib.bugzilla at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: 2013-01/txt/msg02771.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D56155 Bug #: 56155 Summary: [C++0X] enumeration with fixed underlying type - enum literals have wrong type Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: mib.bugzilla@gmail.com For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type. gcc appears to be ignori= ng the underlying type, as the value of E_ in this example is 4 gpp48 bug1.cpp -std=3Dc++0x bug1.cpp: In function =C3=A2int main()=C3=A2: bug1.cpp:4:3: error: static assertion failed: E_ should be 1 static_assert( E_ =3D=3D 1, "E_ should be 1"); ^ enum e_ : unsigned char { Z_, E_=3Dsizeof(Z_) }; #include int main(void) { static_assert( E_ =3D=3D 1, "E_ should be 1"); printf("z is %d e is %d\n", Z_, E_ ); // prints 4 printf("sizeof unsigned char is %d\n", sizeof(unsigned char)); // prints 1 printf("sizeof e_ is %d\n", sizeof(e_)); // prints 1 return 0; }