http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49917
Summary: g++.dg/init/for1.C wrong? Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: marc.gli...@normalesup.org Hello, I am having trouble understanding the test g++.dg/init/for1.C (copied below for reference). For me, i and r are both 0 at first. a gets created. The loop iterates twice, so i is 2 (not 1). a gets destroyed (so r is set to 1) and the test returns 1. I noticed this because unrelated local patches cause a testsuite failure. #include <stdio.h> int i; int r; class A { public: A() { printf("A ctor\n"); } ~A() { printf("A dtor\n"); if (i != 1) r = 1; } }; int main(int argc, char **argv) { for (A a; i < 2; ++i) { printf("iteration %d\n", i); } return r; }