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++/26886] New: missing warning for no return statement in function returning non-void


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


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