1 // PR c++/51213
2 // { dg-do compile { target c++11 } }
3 
4 class C {
5   typedef int type;
6 };
7 
8 template<int>
9 struct I;
10 
11 template<>
12 struct I<2> { };
13 
14 template<class T, class = typename T::type>
15 auto f(int) -> char;
16 
17 template<class>
18 auto f(...) -> char (&)[2];
19 
20 static_assert(sizeof(f<C>(0)) == 2, "Ouch");
21 
22 typedef int testf[sizeof(f<C>(0)) == 2 ? 1 : -1];
23 
24 I<sizeof(f<C>(0))> vf;
25 
26 template<class T>
27 auto g(int) -> decltype(typename T::type(), char());
28 
29 template<class>
30 auto g(...) -> char (&)[2];
31 
32 static_assert(sizeof(g<C>(0)) == 2, "Ouch");
33 
34 typedef int testg[sizeof(g<C>(0)) == 2 ? 1 : -1];
35 
36 I<sizeof(g<C>(0))> vg;
37