This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/46806] -O3 implies 0 <= 8 <= 7
- From: "cstankevitz at toyon dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 5 Dec 2010 18:11:58 +0000
- Subject: [Bug c++/46806] -O3 implies 0 <= 8 <= 7
- Auto-submitted: auto-generated
- References: <bug-46806-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46806
--- Comment #7 from Chris Stankevitz <cstankevitz at toyon dot com> 2010-12-05 18:11:55 UTC ---
If I understand correctly, you are saying "The following is not a valid way to
test whether a user-supplied int is withing the bounds of an enum:"
if (
Eight >= static_cast<int>(eZero) &&
Eight <= static_cast<int>(eSeven))
{
Value = static_cast<TEValue>(Eight);
std::cerr << "0 <= 8 <= 7 (this is bad)\n";
}
What is the correct, valid, portable way to test whether a user-supplied int is
in the range of an enum?
Thank you,
Chris