| 1 |
// PR c++/118523 |
| 2 |
// { dg-do compile { target c++14 } } |
| 3 |
// { dg-options "-O2 -Wall" } |
| 4 |
|
| 5 |
struct __new_allocator { |
| 6 |
constexpr __new_allocator() {} |
| 7 |
__new_allocator(__new_allocator &) {} |
| 8 |
}; |
| 9 |
template <typename> using __allocator_base = __new_allocator; |
| 10 |
template <typename> struct allocator_traits; |
| 11 |
template <typename> struct allocator : __allocator_base<int> {}; |
| 12 |
template <typename _Tp> struct allocator_traits<allocator<_Tp>> { |
| 13 |
using pointer = _Tp *; |
| 14 |
template <typename _Up> using rebind_alloc = allocator<_Up>; |
| 15 |
static void deallocate(allocator<_Tp>, pointer, long); |
| 16 |
}; |
| 17 |
struct __alloc_traits : allocator_traits<allocator<int>> {}; |
| 18 |
struct _Vector_impl_data { |
| 19 |
__alloc_traits::pointer _M_start; |
| 20 |
__alloc_traits::pointer _M_end_of_storage; |
| 21 |
constexpr _Vector_impl_data() : _M_start(), _M_end_of_storage() {} |
| 22 |
}; |
| 23 |
struct _Vector_impl : __alloc_traits::rebind_alloc<int>, _Vector_impl_data {}; |
| 24 |
struct _Vector_base { |
| 25 |
~_Vector_base() { |
| 26 |
_M_deallocate(_M_impl._M_start, |
| 27 |
_M_impl._M_end_of_storage - _M_impl._M_start); |
| 28 |
} |
| 29 |
_Vector_impl _M_impl; |
| 30 |
void _M_deallocate(__alloc_traits::pointer __p, long __n) { |
| 31 |
if (__p) |
| 32 |
__alloc_traits::deallocate(_M_impl, __p, __n); |
| 33 |
} |
| 34 |
}; |
| 35 |
struct vector : protected _Vector_base {}; |
| 36 |
struct S { |
| 37 |
vector a{}; |
| 38 |
}; |
| 39 |
struct B2 { |
| 40 |
B2(S); |
| 41 |
}; |
| 42 |
struct E : B2 { |
| 43 |
E(S opts = {}) : B2{opts} {} |
| 44 |
}; |
| 45 |
void fun() { E{}; } |