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: [email protected]
ReportedBy: [email protected]
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.