aboutsummaryrefslogtreecommitdiff
path: root/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp
blob: 9c6cad8ee2d3d4d8bbe5dde34259313a40fcfe19 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: libcpp-no-exceptions
// XFAIL: availability
// dynarray.cons

// explicit dynarray(size_type c);

// UNSUPPORTED: c++98, c++03, c++11

// The sanitizers replace new/delete with versions that do not throw bad_alloc.
// UNSUPPORTED: sanitizer-new-delete, ubsan


#include <experimental/dynarray>
#include <limits>
#include <new>
#include <cassert>


using std::experimental::dynarray;

int main() {
    try { dynarray<int>((std::numeric_limits<size_t>::max() / sizeof(int)) - 1); }
    catch (std::bad_alloc &) { return 0; }
    catch (...) { assert(false); }
    assert(false);
}