Bug 10929 - [3.3/3.4 regression] -Winline warns about functions for which no definition is visible
Summary: [3.3/3.4 regression] -Winline warns about functions for which no definition i...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P1 normal
Target Milestone: 3.3.1
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-22 11:19 UTC by thor
Modified: 2004-01-17 04:22 UTC (History)
1 user (show)

See Also:
Host: i386-pc-linux-gnu
Target: i386-pc-linux-gnu
Build: i386-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-06-10 19:44:12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description thor 2003-05-22 11:19:55 UTC
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).
Comment 1 Wolfgang Bangerth 2003-05-22 14:33:19 UTC
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.
Comment 2 Andrew Pinski 2003-06-16 17:59:04 UTC
Who ever fixes this, please check if  bug 11067 is fixed too, it looks like the same 
problem but a different test case.
Comment 3 GCC Commits 2003-06-17 23:00:21 UTC
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

Comment 4 GCC Commits 2003-06-17 23:02:09 UTC
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

Comment 5 Jason Merrill 2003-06-17 23:02:40 UTC
Fixed for 3.3.1.