1 // { dg-options "-std=gnu++20" }
2 // { dg-do run { target c++2a } }
3 // { dg-xfail-run-if "AIX operator new" { powerpc-ibm-aix* } }
5 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
22 // C++20 20.11.1.5 unique_ptr creation [unique.ptr.create]
27 #include <testsuite_hooks.h>
29 void* operator new(std::size_t n
)
31 void* p
= std::malloc(n
);
32 std::memset(p
, 0xaa, n
);
36 void operator delete(void* p
) { std::free(p
); }
37 void operator delete(void* p
, std::size_t) { std::free(p
); }
42 std::unique_ptr
<int> a
= std::make_unique_for_overwrite
<int>();
43 VERIFY( a
!= nullptr );
44 unsigned char buf
[sizeof(int)];
45 std::memcpy(buf
, a
.get(), sizeof(buf
));
46 for (unsigned char c
: buf
)
53 std::unique_ptr
<int[]> a
= std::make_unique_for_overwrite
<int[]>(3);
54 VERIFY( a
!= nullptr );
55 unsigned char buf
[3 * sizeof(int)];
56 std::memcpy(buf
, a
.get(), sizeof(buf
));
57 for (unsigned char c
: buf
)