This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Help with bit-field semantics in C and C++
- From: "Steven L. Zook" <SLZook at Qualstar dot com>
- To: "GCC Mailing List \(E-mail\)" <gcc at gcc dot gnu dot org>
- Date: Fri, 27 Aug 2004 14:38:58 -0700
- Subject: RE: Help with bit-field semantics in C and C++
What would happen in this case?
enum eSparse { One = 1, Two = 2, Four = 4, Eight = 8 };
eSpare Sparse = ( eSparse )0x0FFFF;
-----Original Message-----
From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org]On Behalf Of
Gabriel Dos Reis
Sent: Thursday, August 26, 2004 8:06 PM
To: Mike Stump
Cc: 'Roger Sayle'; 'David Carlton'; 'Mark Mitchell'; gcc@gcc.gnu.org;
Dave Korn; 'Joe Buck'
Subject: Re: Help with bit-field semantics in C and C++
Mike Stump <mrs@apple.com> writes:
| On Aug 26, 2004, at 6:26 PM, Gabriel Dos Reis wrote:
| > After exchange on the core reflector, John Spicer came to the
| > agreement that it is the enumeration value that is unspecified.
|
| So
|
| e = (E)7;
|
| printf ("%d\n", (int)e));
|
| should print 3, and not 7 as is does now, and this should work by
| converting integer types into enumeration types, and not by masking
| upon converting enumeration types to ints? Did I get that right?
Yes, the masking happens when converting from integer to enumeration,
not from enumeration to integer.
| We can do that. Wanna ask Tom to put this in his testsuite, so that
| we can get all the other C++ compilers to switch?
OK.
Thanks,
-- Gaby