]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/polymorphic_allocator/lwg3237.cc
tree-optimization/115197 - fix ICE w/ constant in LC PHI and loop distribution
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / polymorphic_allocator / lwg3237.cc
CommitLineData
a945c346 1// Copyright (C) 2020-2024 Free Software Foundation, Inc.
e89100ef
JW
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 3, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
6d0b43f5 18// { dg-do run { target c++20 } }
e89100ef
JW
19
20#include <memory_resource>
21#include <testsuite_hooks.h>
22
23struct large { alignas(1024) int i; };
24
25void
26test01()
27{
28 std::pmr::polymorphic_allocator<large> a;
29 large* p = nullptr;
30 try
31 {
32 p = a.allocate(std::size_t(-1) / 256);
33 VERIFY( false );
34 }
35 catch (const std::bad_array_new_length&)
36 {
37 }
38
39 std::pmr::polymorphic_allocator<int> a2;
40 try
41 {
42 p = a2.allocate_object<large>(std::size_t(-1) / 256);
43 VERIFY( false );
44 }
45 catch (const std::bad_array_new_length&)
46 {
47 }
48}
49
50int
51main()
52{
53 test01();
54}