This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/30794] New: -Wreturn-type acts differently at -O3
- From: "ian at airs dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Feb 2007 18:26:40 -0000
- Subject: [Bug c/30794] New: -Wreturn-type acts differently at -O3
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Compile this simple file with -Wreturn-type -O2:
void *foo () { while (1) ; }
There is no warning. Then compiler it with -Wreturn-type -O3. I get
foo.c:1: warning: no return statement in function returning non-void
This happens because the test for -Wreturn-type in finish_function checks for
DECL_INLINE. At -O3 all functions have DECL_INLINE set. This applies to the
C++ frontend as well.
It's not obvious to me that this particular warning should change depending on
the optimization level. And it's really not obvious that we get the warning at
-O3 and not at -O0, -O1, or -O2.
The same issue arises in both the C and the C++ frontends.
One simple fix might be to check DECL_DECLARED_INLINE_P instead of DECL_INLINE.
--
Summary: -Wreturn-type acts differently at -O3
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30794