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 // GCC 5 does not evaluate static assertions dependent on a template parameter.
10 // UNSUPPORTED: gcc-5
11 
12 // <array>
13 
14 // template <size_t I, class T, size_t N> T& get(array<T, N>& a);
15 
16 // Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify.
17 #if defined(__clang__)
18 #pragma clang diagnostic ignored "-Warray-bounds"
19 #endif
20 
21 #include <array>
22 #include <cassert>
23 
24 
25 // std::array is explicitly allowed to be initialized with A a = { init-list };.
26 // Disable the missing braces warning for this reason.
27 #include "disable_missing_braces_warning.h"
28 
29 int main(int, char**)
30 {
31     {
32         typedef double T;
33         typedef std::array<T, 3> C;
34         C c = {1, 2, 3.5};
35         std::get<3>(c) = 5.5; // expected-note {{requested here}}
36         // expected-error-re@array:* {{static_assert failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}} "Index out of bounds in std::get<> (std::array)"}}
37     }
38 
39   return 0;
40 }
41