Inline constant function pointers
>Submitter-Id: net
>Originator: Ian Turner <vectro@pipeline.com>
>Organization: The Debian Project
>Confidential: no
>Synopsis:
>Severity: non-critical
>Priority: low
>Category: optimization
>Class: change-request
>Release: 3.2.1 (Debian) (Debian unstable)
>Environment:
System: Debian GNU/Linux (unstable)
Architecture: i686
host: i386-linux
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.2 20021212 (Debian prerelease)
>Description:
[ Reported to the Debian BTS as report #173513.
Please CC 173513@bugs.debian.org on replies.
Log of report can be found at http://bugs.debian.org/173513 ]
Currently GCC will not inline a call of a function pointer that is known
at compile time. For example, the following code will still result in
the instruction "call funk" when run with -finline-functions on i386:
#include <stdio.h>
static char* funk() {
return "Hello World.\n";
}
static void funky(char*(*func)()) {
printf("%s", func());
}
void main() {
funky(funk);
}
Although the call to funky is inlined, the call to funk is not, because
in the source code it appears as a call of a function pointer. But as a
consequence of funky being inlined, it would be possible to inline funk
as well.
>How-To-Repeat:
>Fix:
Reply to: