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: Mike Stump <mrs at apple dot com>
- Cc: David Carlton <david dot carlton at sun dot com>, Joe Buck <Joe dot Buck at synopsys dot COM>, Roger Sayle <roger at eyesopen dot com>, Mark Mitchell <mark at codesourcery dot com>, gcc at gcc dot gnu dot org
- Date: 25 Aug 2004 02:56:18 +0200
- Subject: Re: Help with bit-field semantics in C and C++
- Organization: Integrable Solutions
- References: <02A1AE69-F631-11D8-AF5A-003065BDF310@apple.com>
Mike Stump <mrs@apple.com> writes:
| On Tuesday, August 24, 2004, at 04:20 PM, Gabriel Dos Reis wrote:
| > for which the minimum bits of representation is 1, 7 is not an
| > enumeration value. A fortiori, it is not a honest unspecified
| > enumeration value.
|
| The honest qualifier doesn't appear in my definition of the C++
| language; it only has specified and unspecified values.
It was taken from your message I was replying to.
|
| Another way to think about this is to examine:
|
| #include <stdio.h>
| #include <string.h>
|
| enum E { foo = 3 } e;
|
| int
| main() {
| memset (&e, ~(unsigned char)0, sizeof (e));
| printf ("%u\n", (unsigned int)e);
| }
|
| The above program violates no rules of C++. The value printed is
| either specified, or unspecified. Which do you think it is, and if
| specified, which value is printed?
you forgot the option implementation-defined, which actually is the
case here.
-- Gaby