| 1 |
// PR sanitizer/64984 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-fsanitize=vptr -std=gnu++11" } |
| 4 |
|
| 5 |
template <typename X, X> struct K |
| 6 |
{ |
| 7 |
static constexpr X v = 0; |
| 8 |
typedef K t; |
| 9 |
}; |
| 10 |
template <typename...> struct A; |
| 11 |
template <typename X, typename Y> |
| 12 |
struct A<X, Y> : Y |
| 13 |
{ |
| 14 |
}; |
| 15 |
template <typename X> X M (); |
| 16 |
template <typename...> struct B; |
| 17 |
template <typename X, typename Y> |
| 18 |
struct B<X, Y> : K<int, noexcept (static_cast<X>(M<Y>()))> |
| 19 |
{ |
| 20 |
}; |
| 21 |
template <typename X, typename... Y> |
| 22 |
struct G : A<int, B<X, Y...>>::t |
| 23 |
{ |
| 24 |
}; |
| 25 |
template <typename X> struct J : G<X, X&&> |
| 26 |
{ |
| 27 |
}; |
| 28 |
template <typename X> X&& foo (X&); |
| 29 |
template <typename X> X&& bar (X&&); |
| 30 |
template <typename X> struct P |
| 31 |
{ |
| 32 |
P (X& x) : q (x) {} |
| 33 |
X q; |
| 34 |
}; |
| 35 |
template <typename...> struct Q; |
| 36 |
template <typename X> |
| 37 |
struct Q<X> : P<X> |
| 38 |
{ |
| 39 |
typedef P<X> r; |
| 40 |
X& s (Q&); |
| 41 |
Q (X& x) : r (x) {} |
| 42 |
Q (Q&& x) noexcept (J<X>::v) : r (foo<X>(s (x))) |
| 43 |
{ |
| 44 |
} |
| 45 |
}; |
| 46 |
template <typename... X> struct I : Q<X...> |
| 47 |
{ |
| 48 |
I (); |
| 49 |
I (X&... x) : Q<X...>(x...) |
| 50 |
{ |
| 51 |
} |
| 52 |
}; |
| 53 |
template <typename... X> |
| 54 |
I<X&&...> baz (X&&... x) |
| 55 |
{ |
| 56 |
return I <X&&...> (foo<X>(x)...); |
| 57 |
} |
| 58 |
template <typename X> struct F |
| 59 |
{ |
| 60 |
int p; |
| 61 |
void operator[] (X&& x) |
| 62 |
{ |
| 63 |
baz (bar (x)); |
| 64 |
} |
| 65 |
}; |
| 66 |
struct U |
| 67 |
{ |
| 68 |
virtual ~U (); |
| 69 |
}; |
| 70 |
|
| 71 |
int |
| 72 |
main () |
| 73 |
{ |
| 74 |
F<U> m; |
| 75 |
m[U ()]; |
| 76 |
} |