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++/13865] [tree-ssa] dtor runs prematurely for loop-scoped variable


------- Additional Comments From bryner at brianryner dot com  2004-01-26 23:49 -------
This testcase is even simpler:

#include <stdio.h>

class A
{
public:
  A() { printf("A ctor\n"); }
  ~A() { printf("A dtor\n"); }
};

int main(int argc, char **argv)
{
  int i = 0;
  for (A a; i < 2; ++i) {
    printf("iteration %d\n", i);
  }

  return 0;
}

which outputs:

A ctor
A dtor
iteration 0
iteration 1

instead of:

A ctor
iteration 0
iteration 1
A dtor

-- 


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


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