Bugzilla – Bug 104624
new gcc4 warning
Last modified: 2007-09-27 15:52:56 UTC
Compiling the squid3-beta package that came with SUSE 9.3 on the GCC 4.0.2 from SUSE 10.0 Beta 1 gives the following warning/error message: cache_cf.cc: In function ‘void dump_peer(StoreEntry*, const char*, peer*)’: cache_cf.cc:1511: warning: control may reach end of non-void function ‘const char* peer_type_str(peer_t)’ being inlined static const char * peer_type_str(const peer_t type) { switch (type) { case PEER_PARENT: return "parent"; break; case PEER_SIBLING: return "sibling"; break; case PEER_MULTICAST: return "multicast"; break; default: return "unknown"; break; } } All cases seem to be handled so this warning is unjustified AFAICS. Or the warning is not clear enough.
Please read http://www.opensuse.org/index.php/Bugs:gcc on what we need for a GCC bug report. This lacks a preprocessed file, plus commands to reproduce the bug. But I've reproduced it anyway with this: ------------------------------ static const char * peer_type_str(const int type) { switch (type) { default: return "unknown"; break; } } const char * f(const int type) { const char *m = peer_type_str(type); if (m) return m; else return "Ugh"; } --------------------------------- The warning only happens when the function is inlined, and only happens in the C++ compiler. With e.g. "g++ -c -W -Wall -O2". I agree that this warning is incorrect. A workaround is to remove the superflous "break;" after the return. It is dead code.
Especially if -Werror is in effect, this is fatal.
This is btw. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19699, which won't be fixed in the 4.0 line (and is already fixed in 4.1), hence this one also is a WONTFIX.
As long as 4.1 comes with the final SUSE 10 ... ;-)
It won't. 4.1 isn't even released yet, and we are already deep into the beta phase of SL10. That's why it is a WONTFIX, instead of a FIXED. That's unfortunate, but one can't have everything :-|