| 1 |
// PR sanitizer/65583 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-std=c++11 -fsanitize=undefined -Wno-return-type" } |
| 4 |
|
| 5 |
namespace std |
| 6 |
{ |
| 7 |
inline namespace __cxx11 |
| 8 |
{ |
| 9 |
} |
| 10 |
template < typename > class allocator; |
| 11 |
template < class _CharT > struct char_traits; |
| 12 |
namespace __cxx11 |
| 13 |
{ |
| 14 |
template < typename _CharT, typename _Traits = |
| 15 |
char_traits < _CharT >, typename _Alloc = |
| 16 |
allocator < _CharT > >class basic_string; |
| 17 |
typedef basic_string < char >string; |
| 18 |
} |
| 19 |
} |
| 20 |
namespace std |
| 21 |
{ |
| 22 |
template < typename _Tp, _Tp __v > struct integral_constant |
| 23 |
{ |
| 24 |
static constexpr _Tp value = __v; |
| 25 |
}; |
| 26 |
typedef integral_constant < bool, true > true_type; |
| 27 |
} |
| 28 |
namespace __gnu_cxx |
| 29 |
{ |
| 30 |
template < typename _Tp > class new_allocator |
| 31 |
{ |
| 32 |
public: |
| 33 |
typedef long unsigned size_type; |
| 34 |
typedef _Tp value_type; |
| 35 |
template < typename _Tp1 > struct rebind |
| 36 |
{ |
| 37 |
typedef new_allocator < _Tp1 > other; |
| 38 |
}; |
| 39 |
}; |
| 40 |
} |
| 41 |
namespace std |
| 42 |
{ |
| 43 |
template < typename _Tp > using __allocator_base = |
| 44 |
__gnu_cxx::new_allocator < _Tp >; |
| 45 |
template < typename _Tp > class allocator:public __allocator_base < _Tp > |
| 46 |
{ |
| 47 |
}; |
| 48 |
template < typename _Alloc, typename _Tp > class __alloctr_rebind_helper |
| 49 |
{ |
| 50 |
template < typename _Alloc2, typename _Tp2 > |
| 51 |
static constexpr true_type _S_chk (typename _Alloc2::template rebind < |
| 52 |
_Tp2 >::other *); |
| 53 |
public: |
| 54 |
using __type = decltype (_S_chk < _Alloc, _Tp > (nullptr)); |
| 55 |
}; |
| 56 |
template < typename _Alloc, typename _Tp, bool = |
| 57 |
__alloctr_rebind_helper < _Alloc, |
| 58 |
_Tp >::__type::value > struct __alloctr_rebind; |
| 59 |
template < typename _Alloc, typename _Tp > struct __alloctr_rebind <_Alloc, |
| 60 |
_Tp, true > |
| 61 |
{ |
| 62 |
typedef typename _Alloc::template rebind < _Tp >::other __type; |
| 63 |
}; |
| 64 |
template < typename _Alloc > struct allocator_traits |
| 65 |
{ |
| 66 |
typedef typename _Alloc::value_type value_type; |
| 67 |
static value_type *_S_pointer_helper (...); |
| 68 |
typedef decltype (_S_pointer_helper ((_Alloc *) 0)) __pointer; |
| 69 |
typedef __pointer pointer; |
| 70 |
template < typename _Tp > |
| 71 |
static typename _Tp::size_type _S_size_type_helper (_Tp *); |
| 72 |
typedef decltype (_S_size_type_helper ((_Alloc *) 0)) __size_type; |
| 73 |
typedef __size_type size_type; |
| 74 |
template < typename _Tp > using rebind_alloc = |
| 75 |
typename __alloctr_rebind < _Alloc, _Tp >::__type; |
| 76 |
}; |
| 77 |
} |
| 78 |
namespace __gnu_cxx |
| 79 |
{ |
| 80 |
template < typename _Alloc > struct __alloc_traits:std::allocator_traits < |
| 81 |
_Alloc > |
| 82 |
{ |
| 83 |
typedef std::allocator_traits < _Alloc > _Base_type; |
| 84 |
template < typename _Tp > struct rebind |
| 85 |
{ |
| 86 |
typedef typename _Base_type::template rebind_alloc < _Tp > other; |
| 87 |
}; |
| 88 |
}; |
| 89 |
} |
| 90 |
namespace std |
| 91 |
{ |
| 92 |
namespace __cxx11 |
| 93 |
{ |
| 94 |
template < typename _CharT, typename _Traits, |
| 95 |
typename _Alloc > class basic_string |
| 96 |
{ |
| 97 |
typedef typename __gnu_cxx::__alloc_traits < _Alloc >::template rebind < |
| 98 |
_CharT >::other _Char_alloc_type; |
| 99 |
typedef __gnu_cxx::__alloc_traits < _Char_alloc_type > _Alloc_traits; |
| 100 |
typedef _Char_alloc_type allocator_type; |
| 101 |
typedef typename _Alloc_traits::size_type size_type; |
| 102 |
typedef typename _Alloc_traits::pointer pointer; |
| 103 |
struct _Alloc_hider:allocator_type |
| 104 |
{ |
| 105 |
_Alloc_hider (pointer __dat, const _Alloc & __a) |
| 106 |
{ |
| 107 |
} |
| 108 |
}; |
| 109 |
_Alloc_hider _M_dataplus; |
| 110 |
union |
| 111 |
{ |
| 112 |
size_type _M_allocated_capacity; |
| 113 |
}; |
| 114 |
pointer _M_local_data () |
| 115 |
{ |
| 116 |
} |
| 117 |
void _M_dispose () |
| 118 |
{ |
| 119 |
_M_destroy (_M_allocated_capacity); |
| 120 |
} |
| 121 |
void _M_destroy (size_type __size) throw () |
| 122 |
{ |
| 123 |
} |
| 124 |
public: |
| 125 |
basic_string (const _CharT * __s, const _Alloc & __a = _Alloc ()):_M_dataplus (_M_local_data (), |
| 126 |
__a) |
| 127 |
{ |
| 128 |
_M_dispose (); |
| 129 |
} |
| 130 |
}; |
| 131 |
} |
| 132 |
class FileHandle |
| 133 |
{ |
| 134 |
std::string fname; |
| 135 |
FileHandle (const char *fname); |
| 136 |
}; |
| 137 |
FileHandle::FileHandle (const char *fname):fname (fname) |
| 138 |
{ |
| 139 |
} |
| 140 |
} |