1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9
10// UNSUPPORTED: c++03, c++11, c++14, c++17
11
12// These compiler versions and platforms don't enable sized deallocation by default.
13// ADDITIONAL_COMPILE_FLAGS(clang-17): -fsized-deallocation
14// ADDITIONAL_COMPILE_FLAGS(clang-18): -fsized-deallocation
15// ADDITIONAL_COMPILE_FLAGS(apple-clang-15): -fsized-deallocation
16// ADDITIONAL_COMPILE_FLAGS(apple-clang-16): -fsized-deallocation
17// ADDITIONAL_COMPILE_FLAGS(target=x86_64-w64-windows-gnu): -fsized-deallocation
18// ADDITIONAL_COMPILE_FLAGS(target=i686-w64-windows-gnu): -fsized-deallocation
19
20// This test will fail with ASan if the implementation passes different sizes
21// to corresponding allocation and deallocation functions.
22
23#include <memory>
24
25int main(int, char**) {
26 std::allocate_shared<int[]>(a: std::allocator<int>{}, args: 10);
27 std::make_shared<int[]>(args: 10);
28
29 std::allocate_shared<int[10]>(a: std::allocator<int>{});
30 std::make_shared<int[10]>();
31
32 return 0;
33}
34

source code of libcxx/test/libcxx/memory/shared_ptr_array.pass.cpp