1 // { dg-do run } 2 // GROUPS passed copy-ctors 3 /* 4 The old g++ output is 5 6 Item() 7 Compound() 8 Pre foo 9 foo 10 ~Compound() 11 ~Item() 12 Post foo 13 ~Compound() 14 ~Item() 15 16 The output should be something like (produced from ATT 2.1) 17 18 Item() 19 Compound() 20 Pre foo 21 Item(const Item& i) <------ missing above 22 foo 23 ~Compound() 24 ~Item() 25 Post foo 26 ~Compound() 27 ~Item() 28 29 */ 30 31 extern "C" int printf (const char *, ...); 32 extern "C" void exit (int); 33 34 int count = 0; 35 36 void die(int x)37die (int x) 38 { 39 if (x != ++count) 40 { 41 printf ("FAIL\n"); 42 exit (1); 43 } 44 } 45 46 47 class Item { 48 public: Item()49 Item() { die (1); } Item(const Item & i)50 Item(const Item& i) { die (4); } ~Item()51 ~Item() { count++; if (count != 7 && count != 10) die (-1); } 52 }; 53 54 55 class Compound { 56 Item i; 57 public: Compound()58 Compound() { die (2); } ~Compound()59 ~Compound() { count++; if (count != 6 && count != 9) die (-1); } 60 }; 61 62 foo(Compound a)63void foo(Compound a) 64 { 65 die (5); 66 } 67 68 int main()69main() 70 { 71 Compound a; 72 73 die (3); 74 foo(a); 75 76 die (8); 77 78 printf ("PASS\n"); 79 } 80 81