[Bug tree-optimization/39234] New: Call to constant function pointer not inlined
Even when compiled with -O3, the call to f() is not inlined in the following testcase: typedef void (*fptr_t)(); void extfunc(const fptr_t *f); static inline void inlinable() {} void test() { const fptr_t f = inlinable; extfunc(&f); f(); } $ gcc-4.4 -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../gcc-svn/configure --program-suffix=-4.4 --enable-languages=c Thread model: posix gcc version 4.4.0 20090218 (experimental) (GCC) -- Summary: Call to constant function pointer not inlined Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dpirch at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39234
[Bug tree-optimization/39234] Call to constant function pointer not inlined
--- Comment #2 from dpirch at gmail dot com 2009-02-18 22:16 --- extfunc cannot change the value of f, it would lead to undefined behavior. "If an attempt is made to modify an object defined with a const-qualified type through use of an lvalue with non-const-qualified type, the behavior is undefined." (ISO/IEC 9899:TC3, 6.7.3) BTW, the function is actually inlined if f is declared as static const. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39234