Bug 21191 - Bogus "control may reach end of non-void function" warning in inlined function
Summary: Bogus "control may reach end of non-void function" warning in inlined function
Status: RESOLVED DUPLICATE of bug 19699
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.0.0
: P2 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-24 15:20 UTC by Mattias Engdegård
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mattias Engdegård 2005-04-24 15:20:39 UTC
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); }
Comment 1 Andrew Pinski 2005-04-24 15:23:44 UTC

*** This bug has been marked as a duplicate of 19699 ***