File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -98,3 +98,22 @@ struct fred {
98
98
struct fred y [] = { [0] = { .s[0] = 'q' } };
99
99
#endif
100
100
#pragma clang diagnostic pop
101
+
102
+ namespace indices {
103
+ constexpr int first[] = {1 };
104
+ constexpr int firstValue = first[2 ]; // ref-error {{must be initialized by a constant expression}} \
105
+ // ref-note {{cannot refer to element 2 of array of 1}} \
106
+ // expected-error {{must be initialized by a constant expression}} \
107
+ // expected-note {{cannot refer to element 2 of array of 1}}
108
+
109
+ constexpr int second[10 ] = {17 };
110
+ constexpr int secondValue = second[10 ];// ref-error {{must be initialized by a constant expression}} \
111
+ // ref-note {{read of dereferenced one-past-the-end pointer}} \
112
+ // expected-error {{must be initialized by a constant expression}} \
113
+ // expected-note {{read of dereferenced one-past-the-end pointer}}
114
+
115
+ constexpr int negative = second[-2 ]; // ref-error {{must be initialized by a constant expression}} \
116
+ // ref-note {{cannot refer to element -2 of array of 10}} \
117
+ // expected-error {{must be initialized by a constant expression}} \
118
+ // expected-note {{cannot refer to element -2 of array of 10}}
119
+ };
You can’t perform that action at this time.
0 commit comments