1 // RUN: %clang_cc1 %s -Wno-uninitialized -std=c++1z -fsyntax-only -verify 2 3 const extern int arr[]; 4 constexpr auto p = arr; // ok 5 constexpr int f(int i) {return p[i];} // expected-note {{read of dereferenced one-past-the-end pointer}} 6 7 constexpr int arr[] {1, 2, 3}; 8 constexpr auto p2 = arr + 2; // ok 9 constexpr int x = f(2); // ok 10 constexpr int y = f(3); // expected-error {{constant expression}} 11 // expected-note-re@-1 {{in call to 'f({{.*}})'}} 12 13 struct A {int m[];} a; 14 constexpr auto p3 = a.m; // ok 15 constexpr auto p4 = a.m + 1; // expected-error {{constant expression}} expected-note {{constant bound}} 16 17 void g(int i) { 18 int arr[i]; 19 constexpr auto *p = arr + 2; // expected-error {{constant expression}} expected-note {{constant bound}} 20 21 // FIXME: Give a better diagnostic here. The issue is that computing 22 // sizeof(*arr2) within the array indexing fails due to the VLA. 23 int arr2[2][i]; 24 constexpr int m = ((void)arr2[2], 0); // expected-error {{constant expression}} 25 } 26