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: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: "D. Starner" <shalesller at writeme dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 27 Aug 2004 23:35:30 +0200
- Subject: Re: Help with bit-field semantics in C and C++
- Organization: Integrable Solutions
- References: <20040827212642.E57B84BDA8@ws1-1.us4.outblaze.com>
"D. Starner" <shalesller@writeme.com> writes:
| Gabriel Dos Reis <gdr at integrable-solutions dot net> writes:
| > Mike Stump <mrs@apple.com> writes:
| > | 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.
|
| Shouldn't gcc offer a warning on cases where an out-of-range constant
| is assigned to a literal, then? Especially as the correct behavior
| was under dispute by people knowledgable in C.
Probably -- because that is a difference between C and C++.
-- Gaby