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/21191] New: Bogus "control may reach end of non-void function" warning in inlined function


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


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