This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/43680] G++ is too aggressive in optimizing away bounds checking with enums
- From: "bangerth at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Apr 2010 23:16:25 -0000
- Subject: [Bug c++/43680] G++ is too aggressive in optimizing away bounds checking with enums
- References: <bug-43680-114@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from bangerth at gmail dot com 2010-04-07 23:16 -------
(In reply to comment #0)
> I think the C++ standard can definitely be read to allow this optimization
I would most definitely think so. 7.2/6 specifically says that the values
an enum variable can take on are, in your example, 0...3. See, in particular,
footnote 81 in C++98. Everything outside would invoke undefined behavior,
and I like that the compiler can make inferences from that.
Don't we already have a warning that warns about assigning values outside the
range of an enum?
W.
--
bangerth at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org,
| |bangerth at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43680