| 1 |
/* { dg-do compile { target c++11 } } */ |
| 2 |
/* { dg-options "-O2 -fipa-sra" } */ |
| 3 |
|
| 4 |
void __throw_bad_alloc() __attribute__((__noreturn__)); |
| 5 |
void __throw_bad_array_new_length(); |
| 6 |
template <typename> class allocator {}; |
| 7 |
template <typename> struct allocator_traits; |
| 8 |
int *allocate___trans_tmp_2; |
| 9 |
template <typename _Tp> struct allocator_traits<allocator<_Tp>> { |
| 10 |
using allocator_type = allocator<_Tp>; |
| 11 |
using pointer = _Tp *; |
| 12 |
using size_type = long; |
| 13 |
static pointer allocate(allocator_type &, size_type __n) { |
| 14 |
long __trans_tmp_3 = __n; |
| 15 |
if (__builtin_expect(__trans_tmp_3, false)) |
| 16 |
if (__trans_tmp_3) |
| 17 |
__throw_bad_array_new_length(); |
| 18 |
operator new(sizeof(int)); |
| 19 |
return allocate___trans_tmp_2; |
| 20 |
} |
| 21 |
}; |
| 22 |
class throw_allocator_base { |
| 23 |
allocator<int> _M_allocator; |
| 24 |
public: |
| 25 |
int *allocate(long __n) { |
| 26 |
if (__n) |
| 27 |
__throw_bad_alloc(); |
| 28 |
int *a = allocator_traits<allocator<int>>::allocate(_M_allocator, __n); |
| 29 |
return a; |
| 30 |
} |
| 31 |
}; |
| 32 |
template <typename Alloc> void check_allocate_max_size() { |
| 33 |
Alloc a; |
| 34 |
long __trans_tmp_1 = 0; |
| 35 |
a.allocate(__trans_tmp_1 + 1); |
| 36 |
} |
| 37 |
int main() { check_allocate_max_size<throw_allocator_base>(); } |