Try compiling the following code: --------<test.cpp>-------- static inline int foo(int x); int main() { return(foo(17)); } inline int foo(int x) { return(x); } -------------------------- Compiling it with gcc-2.95 gives: bash# gcc -s -O2 -Winline test.cc test.cc: In function `int main()': test.cc:1: warning: can't inline call to `int foo(int)' test.cc:5: warning: called from here ...which is what you would expect. Compiling it with gcc-3.2 results in: bash# gcc -Winline -S -O2 test.cc bash# ...nothing. However, looking at the assembler code: --------<test.s>--------- ... main: pushl %ebp movl %esp, %ebp subl $8, %esp andl $-16, %esp movl $17, (%esp) call _Z3fooi <------- movl %ebp, %esp popl %ebp ret ... --------------------- reveales that the function foo() actually was NOT inlined. I thought, gcc-3 was finally clever enough to perform inlining of functions which are declared inline before but defined after a calling location. If it cannot, it should at least issue the requested warning. Release: 3.2 (release), 3.2.3 (prerelease) and others Environment: Linux ix86 How-To-Repeat: See above.
Fix: http://gcc.gnu.org/ml/gcc-patches/2003-04/msg02133.html
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. The lack of a warning is a regression introduced between 2.95 and 3.0. Actually inlining this function, however, requires unit-at-a-time compilation, which is presently being worked on. W.
From: Steven Bosscher <s.bosscher@student.tudelft.nl> To: gcc-gnats@gcc.gnu.org, wwieser@gmx.de, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org Cc: Subject: Re: c++/10180: [3.2/3.3/3.4 regression] gcc fails to warn about non-inlined function Date: Sun, 06 Apr 2003 02:16:24 +0200 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10180 2.95 didn't have the tree-inliner, right? So this is probably a tree inliner bug.
Responsible-Changed-From-To: unassigned->mmitchel Responsible-Changed-Why: Working on a fix.
From: mmitchel@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: c++/10180 Date: 29 Apr 2003 03:16:57 -0000 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: mmitchel@gcc.gnu.org 2003-04-29 03:16:57 Modified files: gcc : ChangeLog tree-inline.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/warn: Winline-1.C Log message: PR c++/10180 * tree-inline.c (expand_call_inline): Call push_srcloc when encountering EXPR_WITH_FILE_LOCATION. Honor warn_inline. PR c++/10180 * g++.dg/warn/Winline-1.C: New test. 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.485&r2=1.16114.2.486 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.6&r2=1.38.2.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.157&r2=1.2261.2.158 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Winline-1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed in GCC 3.3, GCC 3.4.
From: mmitchel@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: c++/10180 Date: 29 Apr 2003 03:24:28 -0000 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-04-29 03:24:27 Modified files: gcc : ChangeLog tree-inline.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/warn: Winline-1.C Log message: PR c++/10180 * tree-inline.c (expand_call_inline): Call push_srcloc when encountering EXPR_WITH_FILE_LOCATION. Honor warn_inline. PR c++/10180 * g++.dg/warn/Winline-1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.17617&r2=1.17618 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-inline.c.diff?cvsroot=gcc&r1=1.53&r2=1.54 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2629&r2=1.2630 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Winline-1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2