Bug 10180 - [3.2/3.3/3.4 regression] gcc fails to warn about non-inlined function
Summary: [3.2/3.3/3.4 regression] gcc fails to warn about non-inlined function
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: 3.3
Assignee: Mark Mitchell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-21 11:56 UTC by wwieser
Modified: 2004-07-13 17:45 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
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 wwieser 2003-03-21 11:56:00 UTC
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.
Comment 2 Wolfgang Bangerth 2003-03-21 15:14:55 UTC
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.
Comment 3 s.bosscher 2003-04-06 02:16:24 UTC
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.
 
Comment 4 Mark Mitchell 2003-04-23 17:59:56 UTC
Responsible-Changed-From-To: unassigned->mmitchel
Responsible-Changed-Why: Working on a fix.
Comment 5 Mark Mitchell 2003-04-29 03:16:57 UTC
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
 

Comment 6 Mark Mitchell 2003-04-29 03:16:57 UTC
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
 

Comment 7 Mark Mitchell 2003-04-29 03:21:54 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in GCC 3.3, GCC 3.4.
Comment 8 Mark Mitchell 2003-04-29 03:24:28 UTC
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
 

Comment 9 Mark Mitchell 2003-04-29 03:24:28 UTC
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