OSDN Git Service

PR c++/9335
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / template / sfinae17.C
1 // The conversion from D* to B* is ambiguous, but that should not produce
2 // an error, it should remove the first f overload by SFINAE.
3
4 #define static_assert(TEST,STR) \
5   do { int ar[(TEST)?1:-1]; } while (0);
6
7 struct B {};
8
9 struct B1 : B {};
10 struct B2 : B {};
11
12 struct D : B1, B2 {};
13
14 template <class T> T create();
15
16 typedef char one[1];
17 typedef char two[2];
18
19 template <class T>
20     one &f(char (*)[sizeof static_cast<T>(create<D *>())]);
21 template <class T>
22     two &f(...);
23
24 int main()
25 {
26   static_assert(sizeof f<int>(0) == sizeof(two), "");
27   static_assert(sizeof f<B *>(0) == sizeof(two), "");
28 }