1 // { dg-do run } 2 // GROUPS passed copy-ctors 3 // Using Cfront 3.0.1 the programm below prints 4 // 5 // A() 6 // A(const A& a) 7 // ~A() 8 // A(A& a) <---- !!! 9 // ~A() 10 // ~A() 11 // 12 // the g++ 2.2.2 (sparc-sun-sunos4.1) generated code prints 13 // 14 // A() 15 // A(const A& a) 16 // ~A() 17 // A(const A& a) <---- !!! 18 // ~A() 19 // ~A() 20 21 extern "C" int printf (const char *, ...); 22 extern "C" void exit (int); 23 24 int count = 0; 25 26 void die(int x)27die (int x) 28 { 29 if (x != ++count) 30 { 31 printf ("FAIL\n"); 32 exit (1); 33 } 34 } 35 36 class A { 37 public: A()38 A() { die (1); } A(const A & a)39 A(const A& a) { die (2); } A(A & a)40 A(A& a) { die (4); } ~A()41 ~A() { count++; if (count != 3 && count != 5 && count != 6) die (-1); } 42 }; 43 foo1(const A & a)44void foo1(const A& a) { 45 A b = a; 46 } 47 foo2(A & a)48void foo2( A& a) { 49 A b = a; 50 } 51 main()52int main() { 53 A a; 54 55 foo1(a); 56 foo2(a); 57 58 printf ("PASS\n"); 59 } 60