g++-3.3 -Winline generates warnings for functions it cannot inline that it shouldn't even try to inline because they are neither declared as "inline", nor defined in the class body. Save the following as "main.cpp" /* snip */ #include "foo.hpp" int main(int,char) { return foo(); } /* snip */ Save the following as "foo.hpp" /* snip */ int foo(void); /* snip */ Save the following as "foo.cpp" /* snip */ int foo(void) { return 0; } /* snip */ Then compile with $ g++-3.3 -O3 -Winline main.cpp new.cpp Result is a useless warning that int foo(void) could not be inlined. (Correct, but supposed not to be inline-able).
Confirmed. A profoundly unhelpful feature. It triggers on this simple code: --------------------------- int foo(void); int main() { return foo(); } --------------------------- 3.3 and 3.4 warn like this: g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ x.cc -O3 -Winline -c x.cc: In function `int main()': x.cc:1: warning: inlining failed in call to `int foo()' x.cc:4: warning: called from here Warning about functions for which no definition is visible doesn't make much sense. W.
Who ever fixes this, please check if bug 11067 is fixed too, it looks like the same problem but a different test case.
Subject: Bug 10929 CVSROOT: /cvs/gcc Module name: gcc Changes by: jason@gcc.gnu.org 2003-06-17 23:00:17 Modified files: gcc : ChangeLog tree-inline.c gcc/cp : ChangeLog decl.c Added files: gcc/testsuite/g++.dg/warn: Winline-2.C Log message: PR c++/10929 * tree-inline.c (expand_call_inline): Don't warn about failing to inline a function which was made inline by -finline-functions. * cp/decl.c (grokfndecl): Don't mark a function inline for -finline-functions if it isn't defined. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Winline-2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.51&r2=2.52 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-inline.c.diff?cvsroot=gcc&r1=1.61&r2=1.62 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3430&r2=1.3431 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1066&r2=1.1067
Subject: Bug 10929 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: jason@gcc.gnu.org 2003-06-17 23:02:06 Modified files: gcc : ChangeLog tree-inline.c gcc/cp : ChangeLog decl.c Log message: PR c++/10929 * tree-inline.c (expand_call_inline): Don't warn about failing to inline a function which was made inline by -finline-functions. * cp/decl.c (grokfndecl): Don't mark a function inline for -finline-functions if it isn't defined. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.588&r2=1.16114.2.589 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-inline.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.38.2.8&r2=1.38.2.9 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.149&r2=1.3076.2.150 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.47&r2=1.965.2.48
Fixed for 3.3.1.