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 // UNSUPPORTED: c++03
9 // UNSUPPORTED: windows
10 
11 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
12 // UNSUPPORTED: libcxx-no-debug-mode
13 
14 // test array<T, 0>::operator[] raises a debug error.
15 
16 #include <array>
17 #include "test_macros.h"
18 #include "debug_mode_helper.h"
19 
main(int,char **)20 int main(int, char**)
21 {
22   {
23     typedef std::array<int, 0> C;
24     C c = {};
25     C const& cc = c;
26     EXPECT_DEATH( c[0] );
27     EXPECT_DEATH( c[1] );
28     EXPECT_DEATH( cc[0] );
29     EXPECT_DEATH( cc[1] );
30   }
31   {
32     typedef std::array<const int, 0> C;
33     C c = {{}};
34     C const& cc = c;
35     EXPECT_DEATH( c[0] );
36     EXPECT_DEATH( c[1] );
37     EXPECT_DEATH( cc[0] );
38     EXPECT_DEATH( cc[1] );
39   }
40 
41   return 0;
42 }
43