This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Yes, from the point of view of the standard.-----Original Message-----
From: gcc-owner On Behalf Of Mark Mitchell
Sent: 24 August 2004 18:55
To: Roger Sayle
The problem here is that a C++ enum can hold values outside the range of it's type.
enum E { zero = 0x00, one = 0x01 };
void test(int n) { enum E x;
x = (E)n; switch (x) { case zero: foo(); break; case one: bar(); break; } }
int main()
{
test(255);
return 0;
}
What's unspecified is what happens when you convert 255 to E.
Can't we determine by analogy to what happens when you cast 65535 to
short? IOW, isn't this just the same as any other cast of an out-of-range
value to a smaller size?
-- Mark Mitchell CodeSourcery, LLC (916) 791-8304 mark@codesourcery.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |