This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/59031] New: vtable lookup not optimized away
- From: "eraman at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 06 Nov 2013 20:26:56 +0000
- Subject: [Bug c++/59031] New: vtable lookup not optimized away
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59031
Bug ID: 59031
Summary: vtable lookup not optimized away
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: eraman at google dot com
CC: jason at redhat dot com
Created attachment 31175
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31175&action=edit
Proposed patch
The fix to PR c++/11750 at r193504 caused a regression in the following code at
-O0:
class B {
public:
virtual int add (int a, int b) {return a+ b;}
};
class D : public B {
};
int foo (int a, int b) {
D d;
return d.add(a, b);
}
The call d.add(a, b) used to generate a direct call to B::add, but now
generates an indirect call. At -O2, FRE could devirtualize this in some
situations but not always. The attached patch fixes this case and bootstraps
fine. Is this a reasonable fix?