This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/54770] New: sibling call optimization is not applied where it ought to be


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]