The attached test case is testing inlining of const function pointers in a typical "OO code written in C" situation.
The code shows two optimization problems: - a_foo is inlined into main, b_foo is not. The only difference is that new_a() returns a const pointer and new_b() does not. I would have assumed that gcc detects that the pointer coming out of new_b() is const. - p->ops->op2 is never inlined, not even for a, even though the compiler should have enough information to do so (everything that is passed in is const). I assume this is because cloning does not work through function pointers? -- Summary: const function pointer propagation issues with inlining Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: andi-gcc at firstfloor dot org GCC host triplet: x86_64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45632