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++/28236] wrong "control reaches" warning with enums.



------- Comment #5 from manu at gcc dot gnu dot org  2007-01-23 13:57 -------
I don't get this. The enum value can be any integer apart from foo and bar. 
Moreover, since it is undefined, it can be literally anything! So you need a
"default:" case to handle that. 

In the first testcase, without a default case, the function returns (when it
reaches the end) without a value, so the warning is correct.

In the second case, r is not initialized unless __e is X or Y (and if
out-of-range enum values are undefined in C++, __e can be anything!), thus the
warning seems correct as well.

So, is this really a bug?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28236


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