1 // { dg-do run }
2 
3 // Copyright (C) 2000 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 30 Nov 2001 <nathan@nathan@codesourcery.com>
5 
6 // PR 87
7 
8 int assign = 0;
9 int ctor = 0;
10 int assignC = 0;
11 
12 struct A {
13   int i;
14 
15   template<class T>
16   void operator=(const T&) const
17   {
18     assign = 1;
19   }
20 
AA21   A () : i (0) {}
22 
AA23   template <typename T> A (const T &)
24   {
25     ctor = 1;
26   }
27 };
28 
29 struct B : A
30 {
31 };
32 
33 struct C
34 {
35   int i;
36 
CC37   C (int i_) :i (i_) {}
38 
39   template <int I>
40   void operator= (const C &)
41   {
42     assignC = 1;
43   }
44 };
45 
46 
main()47 int main()
48 {
49   const A a;
50   A b;
51   B c;
52 
53   b = a;
54   if (assign)
55     return 5;
56 
57   b.i = 100;
58   c.i = 200;
59 
60   a = b;
61 
62   if (!assign)
63     return 1;
64   if (a.i)
65     return 2;
66 
67   A e (b);
68   if (ctor)
69     return 3;
70 
71   A d (c);
72   if (!ctor)
73     return 4;
74 
75   C c0 (0);
76   C c1 (1);
77 
78   c0 = c1;
79   if (assignC)
80     return 5;
81 
82   return 0;
83 }
84