Feature request: smarter warning about inlining of vararg functions
C. van Reeuwijk
C.vanReeuwijk@twi.tudelft.nl
Mon Aug 17 05:04:00 GMT 1998
The following program:
=-=-=-=-=
// File: va.cc
class X {
int v;
public:
X() { v = 0; }
virtual void foo( int x, ... ){ v = x; }
};
int main()
{
X x;
x.foo( 3 );
}
=-=-=-=-=
Causes the following warning:
=-=-=-=
> g++ -v
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.54/specs
gcc version egcs-2.91.54 19980816 (gcc2 ss-980609 experimental)
> g++ -O -Winline -c va.cc -o va.o
va.cc: In method `void X::foo(int ...)':
va.cc:8: warning: varargs function cannot be inline
va.cc: In function `int main()':
va.cc:8: warning: can't inline call to `void X::foo(int ...)'
va.cc:15: warning: called from here
=-=-=-=
If either '-O' or '-Winline' is omitted, or if '-O' is replaced with
'-finline-functions', there are no warnings.
Strictly speaking, this is correct behavior, since -O makes functions
defined within a class inline by default, and apparently the compiler
cannot inline foo(). Nevertheless, it would be nice if the combination
of flags '-O -Winline' could be used without complaints about these
functions.
--
Kees van Reeuwijk, Delft University of Technology
http://pds.twi.tudelft.nl/~reeuwijk
More information about the Gcc-bugs
mailing list