2 // g++ 1.37.1 bug 900520_06
4 // When an object of a class type is passed into a formal parameter of the
5 // same class type (in a function call) the language definition calls for
6 // this action to be treated like any other form of an initialization of
7 // an object of the given class type.
9 // g++ fails however to invoke the (compiler-supplied) copy constructor for
10 // the class type when a parameter of the class type is passed as an
13 // This causes the following program to exit with a nonzero exit status.
15 // cfront 2.0 passes this test.
17 int base_copy_ctor_called = 0;
18 int member_copy_ctor_called = 0;
22 struct_0 (const struct_0&);
29 struct_0::struct_0 (const struct_0&)
31 base_copy_ctor_called++;
36 struct_1 (const struct_1&);
43 struct_1::struct_1 (const struct_1&)
45 member_copy_ctor_called++;
48 struct struct_2 : public struct_0 {
50 struct_1 struct_1_member;
51 #ifdef MAKE_COPY_CONSTRUCTOR_EXPLICIT
52 struct_2 (const struct_2&);
60 #ifdef MAKE_COPY_CONSTRUCTOR_EXPLICIT
61 struct_2::struct_2 (const struct_2& arg) :
62 struct_0 ((struct_0&)arg),
63 struct_1_member (arg.struct_1_member)
68 void take_struct_2 (struct_2 arg)
74 struct_2 struct_2_object0;
75 take_struct_2 (struct_2_object0);
76 return (base_copy_ctor_called != 1 || member_copy_ctor_called != 1);
79 int main () { return test (); }