The following code should be optimizated out on the tree level but is not 
because we have a cast 
involved when calling the deconstuctor.
int t;
struct base { int i; ~base(){t = i;}};
struct vector : public base { vector(){ i = 2; }};
int f() { vector v; return t;}

extern "C" void abort ();

int main(void)
{
  t = 2;
  if (f() != 2)
   link_error ();
  if (t!= 2)
   link_error ();
  return 0;
}

This might be the case for PR 19786 but I don't know for sure.

-- 
           Summary: C++ front-end produces a cast instead of just &a.b (when
                    call the deconstructor)
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: enhancement
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19817

Reply via email to