summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.jason/conversion6.C
blob: 5f5a51a2f354512428ac485cea99ec8ff730c0b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// { dg-do run  }
// PRMS Id: g++/6034

extern "C" int printf (const char *, ...);

class Base
{
	char x;
};

template <class T>
// remove the public Base inheritance and the problem goes away...
class Container : public Base
{
public:

    Container(const T& aValue): myValue(aValue) { }
    
    operator const T&(void) const
    {
	printf("Container::const T& called\n");
	return myValue;
    }
    
protected:

    T myValue;
};

typedef unsigned short Type;

typedef Container<Type> TypeContainer;

int main(void)
{
    TypeContainer myTypeContainer(2);
    Type t = myTypeContainer;

    printf ("myType = %d\n", t);
    return t != 2;
}