1 // PR ipa/63587
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-O2 -fno-strict-aliasing" }
4
5 template <class> struct A
6 {
7 };
8 template <typename> struct B
9 {
10 template <typename> struct C;
11 };
12 class D;
13 template <typename> class F;
14 struct G
15 {
16 void operator()(const D &, D);
17 };
18 class D
19 {
20 public:
21 D (int);
22 };
23 struct H
24 {
25 H (int);
26 };
27 template <typename _Key, typename, typename, typename _Compare, typename>
28 class I
29 {
30 typedef _Key key_type;
31 template <typename _Key_compare> struct J
32 {
33 _Key_compare _M_key_compare;
34 };
35 J<_Compare> _M_impl;
36
37 public:
38 A<int> _M_get_insert_unique_pos (const key_type &);
39 A<int> _M_get_insert_hint_unique_pos (H &);
40 template <typename... _Args> int _M_emplace_hint_unique (H, _Args &&...);
41 };
42 template <typename _Key, typename _Tp, typename _Compare = G,
43 typename _Alloc = F<A<_Tp> > >
44 class K
45 {
46 typedef _Key key_type;
47 typedef _Key value_type;
48 typedef typename B<_Alloc>::template C<value_type> _Pair_alloc_type;
49 I<key_type, value_type, int, _Compare, _Pair_alloc_type> _M_t;
50
51 public:
52 void operator[](key_type)
53 {
54 _M_t._M_emplace_hint_unique (0);
55 }
56 };
57 template <typename _Key, typename _Val, typename _KeyOfValue,
58 typename _Compare, typename _Alloc>
59 A<int>
_M_get_insert_unique_pos(const key_type & p1)60 I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos (
61 const key_type &p1)
62 {
63 _M_impl._M_key_compare (p1, 0);
64 return A<int>();
65 }
66 template <typename _Key, typename _Val, typename _KeyOfValue,
67 typename _Compare, typename _Alloc>
68 A<int>
_M_get_insert_hint_unique_pos(H &)69 I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_hint_unique_pos (
70 H &)
71 {
72 _M_get_insert_unique_pos (0);
73 return A<int>();
74 }
75 template <typename _Key, typename _Val, typename _KeyOfValue,
76 typename _Compare, typename _Alloc>
77 template <typename... _Args>
78 int
_M_emplace_hint_unique(H p1,_Args &&...)79 I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique (
80 H p1, _Args &&...)
81 {
82 _M_get_insert_hint_unique_pos (p1);
83 return 0;
84 }
85 namespace {
86 struct L;
87 }
88 void
fn1()89 fn1 ()
90 {
91 K<D, L> a;
92 a[0];
93 K<D, int> b;
94 b[0];
95 }
96