This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80458] New: [-Wreturn-type] false negative on missing return statement in a member function
- From: "skvadrik at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 18 Apr 2017 22:20:02 +0000
- Subject: [Bug c++/80458] New: [-Wreturn-type] false negative on missing return statement in a member function
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80458
Bug ID: 80458
Summary: [-Wreturn-type] false negative on missing return
statement in a member function
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: skvadrik at gmail dot com
Target Milestone: ---
On the following example (missing return statement in a member function) GCC
emits no warning:
$ cat 1.cc
#include <stdlib.h> // exit
extern void *f();
class Bag {
void *g() {
void *p = f();
if (!p) exit(1);
}
};
$ g++ -c -Wall -Wextra -O2 1.cc
$
If I comment out class definition, GCC emits warning:
$ cat 1.cc
#include <stdlib.h> // exit
extern void *f();
//class Bag {
void *g() {
void *p = f();
if (!p) exit(1);
}
//};
$ g++ -c -Wall -Wextra -O2 1.cc
1.cc: In function ‘void* g()’:
1.cc:7:5: warning: control reaches end of non-void function [-Wreturn-type]
}
^
$