[Bug c++/54770] New: sibling call optimization is not applied where it ought to be
andy.m.jost at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 1 19:14:00 GMT 2012
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.
More information about the Gcc-bugs
mailing list