|
|
Mael wrote:
>> WAIT. Because it seems you [Mael] are using an outdated version of gcc.
>
> g++ -v
> version gcc 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
>
> I think that -Winline will warn if the function cannot be inlined (looking
> at gcc doc this can happen for example if it uses varargs), but here the
> functions *are* inlinable(? :)
>
Well, the info states:
Using `-Winline' will warn when a function marked `inline' could not be
substituted, and will give the reason for the failure.
And when using gcc-2.95, I get tons of warnings about functions which
cannot be inlined which I do not get with gcc-3.2.
OTOH, I made a simple test case which proves that you are right:
--------<test.cpp>--------
static inline int foo(int x);
int main()
{
return(foo(17));
}
inline int foo(int x)
{ return(x); }
--------------------------
In the above case, foo() will actually NOT be inlined and gcc will
not say a word about that. However, when yo move the foo() def above
main(), then it WILL be inlined.
HOWEVER, compiling the above code with gcc-2.95.3, you get:
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 I would definitely expect -Winline to produce in this
case!
When moving foo() def above main(), the warning goes away and foo()
gets properly inlined.
I'll talk to some gcc developer about that.
Wolfgang
Post a reply to this message
|
|