[Bug c++/26886] New: missing warning for no return statement in function returning non-void

jpoland at cadence dot com gcc-bugzilla@gcc.gnu.org
Mon Mar 27 16:11:00 GMT 2006


Missing warning for no return statement in function returning non-void

The following code when compiled with -Wreturn-type -c 
prints a warning about function test2 which is a non-void function missing a
return statement, but it does not print a warning about test1. 

tmp.C: In function `int test2()':
tmp.C:17: warning: control reaches end of non-void function


If I comment out both lines in test1, I then get both warnings:

tmp.C: In member function `int foo::test1()':
tmp.C:10: warning: no return statement in function returning non-void
tmp.C: In function `int test2()':
tmp.C:17: warning: control reaches end of non-void function


///////////////////////

int xxx = 999;

class foo
{
public:
    int test1()
        {
            if (xxx == 10)
                return 0;
        }
};

int test2()
{
    if (xxx == 10)
        return 0;
}
///////////////////////

I need it to warn about test1.


-- 
           Summary: missing warning for no return statement in function
                    returning non-void
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jpoland at cadence dot com


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



More information about the Gcc-bugs mailing list