This is the mail archive of the gcc-bugs@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]

[Bug c++/43680] G++ is too aggressive in optimizing away bounds checking with enums



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]