This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/34217] New: Optimisation of virtual functions confused by inlining.
- From: "chris at bubblescope dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Nov 2007 19:36:00 -0000
- Subject: [Bug c++/34217] New: Optimisation of virtual functions confused by inlining.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider the following code:
struct bar
{ virtual int get_val() { return 1; } };
int inline get_value(bar* b) { return b->get_val(); }
int main(void)
{
bar b;
//return (&b)->get_val(); #1
return get_value(&b); #2
}
Using #1, the compiler optimises away all the code with -O. With #2, when
get_value is inlined into main, the optimiser seems to 'forget' it actually
knows exactly the type of b and performs an unnecessary virtual function call.
Chris
--
Summary: Optimisation of virtual functions confused by inlining.
Product: gcc
Version: 4.2.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: chris at bubblescope dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34217