Bug 104624 - new gcc4 warning
Summary: new gcc4 warning
Status: VERIFIED WONTFIX
Alias: None
Product: SUSE LINUX 10.0
Classification: openSUSE
Component: Development (show other bugs)
Version: Beta 1
Hardware: All Linux
: P5 - None : Minor
Target Milestone: ---
Assignee: Michael Matz
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-14 19:16 UTC by Jan Engelhardt
Modified: 2007-09-27 15:52 UTC (History)
0 users

See Also:
Found By: Beta-Customer
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Engelhardt 2005-08-14 19:16:30 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.
Comment 1 Michael Matz 2005-08-15 14:16:05 UTC
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. 
Comment 2 Jan Engelhardt 2005-08-15 14:23:23 UTC
Especially if -Werror is in effect, this is fatal.
Comment 3 Michael Matz 2005-08-15 14:41:57 UTC
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.  
Comment 4 Jan Engelhardt 2005-08-15 14:57:08 UTC
As long as 4.1 comes with the final SUSE 10 ... ;-)
Comment 5 Michael Matz 2005-08-15 15:13:33 UTC
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 :-|