This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54770] New: sibling call optimization is not applied where it ought to be
- From: "andy.m.jost at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 01 Oct 2012 19:14:04 +0000
- Subject: [Bug c++/54770] New: sibling call optimization is not applied where it ought to be
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54770
Bug #: 54770
Summary: sibling call optimization is not applied where it
ought to be
Classification: Unclassified
Product: gcc
Version: 4.5.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: andy.m.jost@gmail.com
Created attachment 28317
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28317
Source file
"g++ -O2 -Wall -Wextra" fails to apply the sibling call optimization in the
attached program. The interesting portion is shown below:
struct MainNode : Node
{
MainNode(NodePtr const & arg_) : Node(), arg(arg_) {}
virtual ~MainNode() {}
NodePtr arg;
virtual void H()
{
// Extra scope guarantees there are no destructors following the tail call.
{
NodePtr tmp(arg);
this->~Node();
new(this) MainNode(tmp);
}
this->H(); // sibling call
}
};
NodePtr is a class type. If it is simply changed to Node *, then the
optimization is applied.