2 // { dg-do compile { target c++11 } }
4 #define SA(X) static_assert((X),#X)
6 constexpr char s[] = "abc";
7 constexpr char c1 = *(&s[0] + 0);
8 constexpr char c2 = *(&s[0] + 1);
9 constexpr char c3 = *(&s[1] + 0);
10 constexpr char c4 = *(&s[1] + 1);
11 constexpr char c5 = *(&s[2] + 0);
12 constexpr char c6 = *(&s[0] + 2);
13 constexpr char c7 = *(&s[2] + 1);
15 constexpr char d1 = *(&s[4] - 0); // { dg-error "array subscript" }
16 constexpr char d2 = *(&s[4] - 1);
17 constexpr char d3 = *(&s[4] - 2);
18 constexpr char d4 = *(&s[4] - 3);
19 constexpr char d5 = *(&s[4] - 4);
20 constexpr char d6 = *(&s[4] - 5); // { dg-error "array subscript" }
22 /* Don't accept invalid stuff. */
23 constexpr char e1 = *(&s[5] - 1); // { dg-error "array subscript" }
24 constexpr char e2 = *(&s[5] - 2); // { dg-error "array subscript" }
25 constexpr char e3 = *(&s[5] - 3); // { dg-error "array subscript" }
39 constexpr int l[] = { 'c', 'd', 'e', '\0' };
40 constexpr int i1 = *(&l[0] + 0);
41 constexpr int i2 = *(&l[0] + 1);
42 constexpr int i3 = *(&l[1] + 0);
43 constexpr int i4 = *(&l[1] + 1);
44 constexpr int i5 = *(&l[2] + 0);
45 constexpr int i6 = *(&l[0] + 2);
46 constexpr int i7 = *(&l[2] + 1);
48 constexpr char j1 = *(&l[4] - 0); // { dg-error "array subscript" }
49 constexpr char j2 = *(&l[4] - 1);
50 constexpr char j3 = *(&l[4] - 2);
51 constexpr char j4 = *(&l[4] - 3);
52 constexpr char j5 = *(&l[4] - 4);
53 constexpr char j6 = *(&l[4] - 5); // { dg-error "array subscript" }
55 /* Don't accept invalid stuff. */
56 constexpr char k1 = *(&l[5] - 1); // { dg-error "array subscript" }
57 constexpr char k2 = *(&l[5] - 2); // { dg-error "array subscript" }
58 constexpr char k3 = *(&l[5] - 3); // { dg-error "array subscript" }