This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21191] New: Bogus "control may reach end of non-void function" warning in inlined function
- From: "mattias at virtutech dot se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Apr 2005 15:20:41 -0000
- Subject: [Bug c/21191] New: Bogus "control may reach end of non-void function" warning in inlined function
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Inlined functions can give rise to bogus warnings when they contain statically
determined branches. Testcase:
static inline int f(int x) { if (1) return 17; }
int h(int z) { return f(z); }
foo$ gcc -O2 -Wall -c foo.c
foo.c: In function 'h':
foo.c:2: warning: control may reach end of non-void function 'f' being inlined
This kind of code is not uncommon, nor bad style, and makes -Werror useless.
This is a regression from gcc 3.4.0.
The same warning is given with:
static inline int f(int x, int q) { if (q) return 17; }
int h(int z) { return f(z, 1); }
--
Summary: Bogus "control may reach end of non-void function"
warning in inlined function
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mattias at virtutech dot se
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21191