1 // PR c++/57047
2 // { dg-require-effective-target c++11 }
3 
4 template <typename>
5 struct A;
6 template <typename T>
7 struct A <T &>
8 {
9   typedef T type;
10 };
11 template <typename T>
12 constexpr T && foo (typename A <T>::type & __t) noexcept
13 {
14   return static_cast <T &&>(__t);
15 }
16 template <class T1, class T2>
17 struct B
18 {
19   T1 t1;
20   T2 t2;
21   template <class U>
22   constexpr B (U && __x, const T2 & __y) : t1 (foo <U> (__x)), t2 (__y) {}
23 };
24 static inline constexpr bool
25 fn1 (const char c)
26 {
27   return ('0' <= c) && (c <= '9');
28 }
29 static inline constexpr bool
30 fn2 (const char c)
31 {
32   return (('A' <= c) && (c <= 'Z')) || (('a' <= c) && (c <= 'z'));
33 }
34 static constexpr bool
35 fn3 (const char *const x)
36 {
37   return (x[1] == '\0' && x[0] == ']') ? true : (!fn1 (x[0])) ? false : fn3 (&x[1]);
38 }
39 static constexpr bool
40 fn4 (const char *const x)
41 {
42   return (x[0] == '\0') ? fn3 (&x[1]) : fn4 (&x[1]);
43 }
44 static inline constexpr bool
45 fn5 (const char *const x)
46 {
47   return fn2 (x[0]) ? fn4 (x) : false;
48 }
49 struct C final
50 {
51   constexpr C (const char *const t1) : c (fn5 (t1) ? 199 : 69) {}
52   unsigned c;
53 };
54 B <C, C> p ("a", "b");
55