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: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Mike Stump <mrs at apple dot com>
- Cc: David Carlton <david dot carlton at sun dot com>,Gabriel Dos Reis <gdr at integrable-solutions dot net>,Roger Sayle <roger at eyesopen dot com>,Mark Mitchell <mark at codesourcery dot com>, gcc at gcc dot gnu dot org
- Date: Tue, 24 Aug 2004 16:23:16 -0700
- Subject: Re: Help with bit-field semantics in C and C++
- References: <yf2u0usxlg5.fsf@kealia.sfbay.sun.com> <96CE33DE-F622-11D8-AF5A-003065BDF310@apple.com>
[ here E is a four-valued enum, 0,1,2,3 ]
On Tue, Aug 24, 2004 at 04:09:02PM -0700, Mike Stump wrote:
> (E)n, where n is an int with value, say of 7, is permitted by the
> standard to take on the value 7. This is because the text of the
> standard says the value is unspecified. 7 is a unspecified value,
> honest.
I agree with you so far; (E)n might be 7.
The next question, then, is whether, despite this, a compiler is allowed
to implement a switch on a variable of type E as a jump table, in such a
way that a value outside of [0,3] malfunctions (jumps to a random address).
Let's leave to one side whether this is a good idea. Is it permitted?