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
Summary: const function pointer propagation issues with inlining
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: andi-gcc at firstfloor dot org
GCC host triplet: x86_64-linux