1 // g++ 1.37.1 bug 900520_06
3 // When an object of a class type is passed into a formal parameter of the
4 // same class type (in a function call) the language definition calls for
5 // this action to be treated like any other form of an initialization of
6 // an object of the given class type.
8 // g++ fails however to invoke the (compiler-supplied) copy constructor for
9 // the class type when a parameter of the class type is passed as an
12 // This causes the following program to exit with a nonzero exit status.
14 // cfront 2.0 passes this test.
16 int base_copy_ctor_called = 0;
17 int member_copy_ctor_called = 0;
21 struct_0 (const struct_0&);
28 struct_0::struct_0 (const struct_0&)
30 base_copy_ctor_called++;
35 struct_1 (const struct_1&);
42 struct_1::struct_1 (const struct_1&)
44 member_copy_ctor_called++;
47 struct struct_2 : public struct_0 {
49 struct_1 struct_1_member;
50 #ifdef MAKE_COPY_CONSTRUCTOR_EXPLICIT
51 struct_2 (const struct_2&);
59 #ifdef MAKE_COPY_CONSTRUCTOR_EXPLICIT
60 struct_2::struct_2 (const struct_2& arg) :
61 struct_0 ((struct_0&)arg),
62 struct_1_member (arg.struct_1_member)
67 void take_struct_2 (struct_2 arg)
73 struct_2 struct_2_object0;
74 take_struct_2 (struct_2_object0);
75 return (base_copy_ctor_called != 1 || member_copy_ctor_called != 1);
78 int main () { return test (); }