Lines Matching refs:constexpr
13 template<typename T> constexpr T id(const T &t) { return t; } in id()
14 template<typename T> constexpr T min(const T &a, const T &b) { in min()
17 template<typename T> constexpr T max(const T &a, const T &b) { in max()
20 template<typename T, size_t N> constexpr T *begin(T (&xs)[N]) { return xs; } in begin()
21 template<typename T, size_t N> constexpr T *end(T (&xs)[N]) { return xs + N; } in end()
24 constexpr int zero() const { return 0; } in zero()
38 constexpr B *p = &d;
39 constexpr C *q = &d;
45 constexpr B &pp = d;
46 constexpr C &qq = d;
51 constexpr V *v = p;
52 constexpr V *w = q;
53 constexpr V *x = (A*)p;
73 constexpr int n1 = 0;
74 constexpr int n2 = const_cast<int&>(n1);
75 constexpr int *n3 = const_cast<int*>(&n1);
76 constexpr int n4 = *const_cast<int*>(&n1);
77 constexpr const int * const *n5 = const_cast<const int* const*>(&n3);
78 constexpr int **n6 = const_cast<int**>(&n3);
79 constexpr int n7 = **n5;
80 constexpr int n8 = **n6;
84 constexpr int n9 = (const_cast<A&&>(A{123})).n;
112 constexpr int &Recurse3 = Recurse2; // expected-error {{must be initialized by a constant expressio…
117 constexpr int RecurseC = RecurseB; // expected-error {{must be initialized by a constant expression…
130 constexpr int Sum(int a = 0, const int &b = 0, const int *c = &z, char d = 0) { in Sum()
134 constexpr int eight = 8;
135 constexpr const int twentyseven = 27;
147 constexpr int F(int a, ...) { return a; } in F()
158 constexpr int fib(int n) { return n > 1 ? fib(n-1) + fib(n-2) : n; } in fib()
161 constexpr int gcd_inner(int a, int b) { in gcd_inner()
164 constexpr int gcd(int a, int b) { in gcd()
174 constexpr int f() { return 1; } in f()
183 static constexpr int k = 42;
184 static constexpr int f(int n) { return n * k + 2; } in f()
187 constexpr int n = s.f(19);
192 constexpr int (*sf1)(int) = &S::f;
193 constexpr int (*sf2)(int) = &s.f;
194 constexpr const int *sk = &s.k;
200 constexpr const int &ObscureTheTruth(const int &a) { return a; } in ObscureTheTruth()
201 constexpr const int &MaybeReturnJunk(bool b, const int a) { // expected-note 2{{declared here}} in MaybeReturnJunk()
205 …constexpr int a = MaybeReturnJunk(true, 0); // expected-error {{constant expression}} expected-not…
207 constexpr const int MaybeReturnNonstaticRef(bool b, const int a) { in MaybeReturnNonstaticRef()
211 constexpr int b = MaybeReturnNonstaticRef(true, 0); // ok
213 constexpr int InternalReturnJunk(int n) { in InternalReturnJunk()
216 …constexpr int n3 = InternalReturnJunk(0); // expected-error {{must be initialized by a constant ex…
218 constexpr int LToR(int &n) { return n; } in LToR()
219 constexpr int GrabCallersArgument(bool which, int a, int b) { in GrabCallersArgument()
229 constexpr int f(int n, const int *a, const int *b, const int *c) { in f()
236 constexpr int g(int n, int a, int b, int c) { in g()
245 constexpr int Double(int n) { return 2 * n; } in Double()
246 constexpr int Triple(int n) { return 3 * n; } in Triple()
247 constexpr int Twice(int (*F)(int), int n) { return F(F(n)); } in Twice()
248 constexpr int Quadruple(int n) { return Twice(Double, n); } in Quadruple()
249 constexpr auto Select(int n) -> int (*)(int) { in Select()
252 constexpr int Apply(int (*F)(int), int n) { return F(n); } // expected-note {{subexpression}} in Apply()
256 …constexpr int Invalid = Apply(Select(0), 0); // expected-error {{must be initialized by a constant…
265 constexpr bool g1 = &x == &y;
266 constexpr bool g2 = &x != &y;
267 constexpr bool g3 = &x <= &y; // expected-error {{must be initialized by a constant expression}}
268 constexpr bool g4 = &x >= &y; // expected-error {{must be initialized by a constant expression}}
269 constexpr bool g5 = &x < &y; // expected-error {{must be initialized by a constant expression}}
270 constexpr bool g6 = &x > &y; // expected-error {{must be initialized by a constant expression}}
282 constexpr bool n3 = 0 <= &y; // expected-error {{must be initialized by a constant expression}}
283 constexpr bool n4 = 0 >= &y; // expected-error {{must be initialized by a constant expression}}
284 constexpr bool n5 = 0 < &y; // expected-error {{must be initialized by a constant expression}}
285 constexpr bool n6 = 0 > &y; // expected-error {{must be initialized by a constant expression}}
289 constexpr bool n9 = &x <= 0; // expected-error {{must be initialized by a constant expression}}
290 constexpr bool n10 = &x >= 0; // expected-error {{must be initialized by a constant expression}}
291 constexpr bool n11 = &x < 0; // expected-error {{must be initialized by a constant expression}}
292 constexpr bool n12 = &x > 0; // expected-error {{must be initialized by a constant expression}}
301 constexpr S* sptr = &s;
302 constexpr bool dyncast = sptr == dynamic_cast<S*>(sptr); // expected-error {{constant expression}} …
330 constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL; // expected-error {{must be …
331 constexpr bool litaddress = "foo" == "foo"; // expected-error {{must be initialized by a constant e…
338 constexpr int f(const int &r) { return r; } in f()
339 constexpr int n = f(1);
341 constexpr bool same(const int &a, const int &b) { return &a == &b; } in same()
342 constexpr bool sameTemporary(const int &n) { return same(n, n); } in sameTemporary()
352 constexpr B b1 { { 1 }, { 2 } }; // expected-note {{temporary created here}}
356 constexpr B &&b2 { { 3 }, { 4 } }; // expected-note {{temporary created here}}
360 constexpr thread_local B b3 { { 1 }, { 2 } }; // expected-error {{constant expression}} expected-no…
362 constexpr static B b1 { { 1 }, { 2 } }; // ok in foo()
363 …constexpr thread_local B b2 { { 1 }, { 2 } }; // expected-error {{constant expression}} expected-n… in foo()
364 …constexpr B b3 { { 1 }, { 2 } }; // expected-error {{constant expression}} expected-note {{referen… in foo()
367 constexpr B &&b4 = ((1, 2), 3, 4, B { {10}, {{20}} }); // expected-warning 4{{unused}}
371 constexpr B b5 = B{ {0}, {0} }; // expected-error {{constant expression}} expected-note {{reference…
379 constexpr B a = { A{0} }; // ok
380 …constexpr B b = { A(A{0}) }; // expected-error {{constant expression}} expected-note {{reference t…
386 constexpr init_list_2_init_list_3_ints ils = { { { { 1, 2, 3 } }, { { 4, 5, 6 } } } };
391 constexpr int strcmp_ce(const char *p, const char *q) { in strcmp_ce()
398 constexpr int MangleChars(const Char *p) { in MangleChars()
408 constexpr char c0 = "nought index"[0];
409 constexpr char c1 = "nice index"[10];
410 constexpr char c2 = "nasty index"[12]; // expected-error {{must be initialized by a constant expres…
411 constexpr char c3 = "negative index"[-1]; // expected-error {{must be initialized by a constant exp…
412 constexpr char c4 = ((char*)(int*)"no reinterpret_casts allowed")[14]; // expected-error {{must be …
414 constexpr const char *p = "test" + 2;
417 constexpr const char *max_iter(const char *a, const char *b) { in max_iter()
420 constexpr const char *max_element(const char *a, const char *b) { in max_element()
424 constexpr char str[] = "the quick brown fox jumped over the lazy dog";
425 constexpr const char *max = max_element(begin(str), end(str));
440 constexpr T() : c{"foo"} {} in T()
442 constexpr T t;
455 } constexpr u = { { L"test" }, 0 };
460 constexpr V() : c("hi!") {} in V()
465 constexpr unsigned char a[] = ("foo"), b[] = {"foo"}, c[] = {("foo")},
482 constexpr auto Sum(Iter begin, Iter end) -> decltype(+*begin) { in Sum()
486 constexpr int xs[] = { 1, 2, 3, 4, 5 };
487 constexpr int ys[] = { 5, 4, 3, 2, 1 };
488 constexpr int sum_xs = Sum(begin(xs), end(xs));
491 constexpr int ZipFoldR(int (*F)(int x, int y, int c), int n, in ZipFoldR()
501 constexpr int MulAdd(int x, int y, int c) { return x * y + c; } in MulAdd()
502 constexpr int InnerProduct = ZipFoldR(MulAdd, 5, xs, ys, 0);
505 constexpr int SubMul(int x, int y, int c) { return (x - y) * c; } in SubMul()
506 constexpr int DiffProd = ZipFoldR(SubMul, 2, xs+3, ys+3, 1);
512 constexpr const int *p = xs + 3;
513 constexpr int xs4 = p[1]; // ok
514 constexpr int xs5 = p[2]; // expected-error {{constant expression}} expected-note {{read of derefer…
515 constexpr int xs6 = p[3]; // expected-error {{constant expression}} expected-note {{cannot refer to…
516 constexpr int xs0 = p[-3]; // ok
517 constexpr int xs_1 = p[-4]; // expected-error {{constant expression}} expected-note {{cannot refer …
519 constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
527 constexpr int err_zs_1_2_0_0 = zs[1][2][0][0]; // expected-error {{constant expression}} expected-n…
529 constexpr int fail(const int &p) { in fail()
536 constexpr int arr[40] = { 1, 2, 3, [8] = 4 }; // expected-warning {{C99 feature}}
537 constexpr int SumNonzero(const int *p) { in SumNonzero()
540 constexpr int CountZero(const int *p, const int *q) { in CountZero()
547 constexpr ArrayElem() : n(0) {} in ArrayElem()
549 constexpr int f() const { return n; } in f()
552 constexpr ArrayRVal() {} in ArrayRVal()
557 constexpr int selfref[2][2][2] = {
593 constexpr int n = g(); in f()
595 constexpr int m = this->g(); // ok, could be constexpr in f()
603 struct A { constexpr A(int a, int b) : k(a + b) {} int k; }; in A()
604 constexpr int fn(const A &a) { return a.k; } in fn()
607 struct B { int n; int m; } constexpr b = { 0, b.n };
609 constexpr C(C *this_) : m(42), n(this_->m) {} // ok in C()
614 constexpr D() : c(&c) {} in D()
619 constexpr E() : p(&p) {} in E()
622 constexpr const E &e1 = E();
625 constexpr E e2 = E();
627 constexpr E e3;
632 constexpr F() : p(&f.p) {} in F()
635 constexpr F f;
639 constexpr T(T *p) : u1(), u2(p) {} in T()
641 constexpr U1() {} in U1()
645 constexpr U2(T *p) : c(p->u1.b) {} in U2()
649 constexpr G() : t(&t) {} in G()
650 } constexpr g;
663 constexpr S(int n, const S *p) : a(5), b(n), p(p), d(n), q("hello") {} in S()
670 constexpr bool CheckS(const S &s) { in CheckS()
677 constexpr Arr() : arr{'x', 'y', 'z'} {} in Arr()
679 constexpr int hash(Arr &&a) { in hash()
682 constexpr int k = hash(Arr());
694 constexpr AggregateInit agg1 = { "hello"[0] };
705 static constexpr const unsigned char uc[] = { "foo" };
712 constexpr B(int n) : a(n) {} in B()
716 constexpr D(int n) : B(n) {} in D()
718 constexpr D d(3);
723 struct Bottom { constexpr Bottom() {} }; in Bottom()
725 constexpr Base(int a = 42, const char *b = "test") : a(a), b(b) {} in Base()
730 constexpr Base2(const int &r) : r(r) {} in Base2()
735 constexpr Derived() : Base(76), Base2(a) {} in Derived()
739 constexpr bool operator==(const Base &a, const Base &b) { in operator ==()
743 constexpr Base base;
744 constexpr Base base2(76);
745 constexpr Derived derived;
756 constexpr Bottom &bot1 = (Base&)derived;
757 constexpr Bottom &bot2 = (Base2&)derived;
760 constexpr Bottom *pb1 = (Base*)&derived;
761 constexpr Bottom *pb2 = (Base2*)&derived;
766 constexpr Base2 &fail = (Base2&)bot1; // expected-error {{constant expression}} expected-note {{can…
767 constexpr Base &fail2 = (Base&)*pb2; // expected-error {{constant expression}} expected-note {{cann…
768 constexpr Base2 &ok2 = (Base2&)bot2;
771 constexpr Base2 *pfail = (Base2*)pb1; // expected-error {{constant expression}} expected-note {{can…
772 constexpr Base *pfail2 = (Base*)&bot2; // expected-error {{constant expression}} expected-note {{ca…
773 constexpr Base2 *pok2 = (Base2*)pb2;
781 constexpr Base *nullB = 42 - 6 * 7; // expected-error {{cannot initialize a variable of type 'Class…
782 constexpr Base *nullB1 = 0;
800 constexpr T(int n) : k(5*n - 3) {} in T()
801 constexpr operator int() const { return k; } in operator int()
806 constexpr S(int n) : k(2*n + 1) {} in S()
807 constexpr operator int() const { return k; } in operator int()
808 constexpr operator T() const { return T(k); } in operator T()
812 constexpr bool check(T a, T b) { return a == b.k; } in check()
820 constexpr (operator int)() const { return 0; }
829 constexpr int f() const { return 0; } in f()
830 static constexpr int g() { return 0; } in g()
832 constexpr int x = f(); // expected-error {{must be initialized by a constant}} in h()
834 constexpr int y = this->f(); // expected-error {{must be initialized by a constant}} in h()
836 constexpr int z = g(); in h()
846 constexpr S() {} in S()
847 constexpr int f() const;
848 constexpr int g() const;
851 constexpr T(int n) : S(), n(n) {} in T()
854 constexpr int S::f() const { in f()
857 constexpr int S::g() const { in g()
869 constexpr int f(const S &s) { in f()
872 constexpr int n = f(T(5));
875 constexpr bool b(int n) { return &n; } in b()
882 constexpr int k = NonLiteral().f(); // expected-error {{constant expression}} expected-note {{non-l…
893 constexpr U u[4] = { { .a = 0 }, { .b = 1 }, { .a = 2 }, { .b = 3 } }; // expected-warning 4{{C99 f…
901 constexpr U v = {};
905 constexpr Empty e = {};
908 constexpr U x = {42};
909 constexpr U y = x;
917 constexpr A(int n) : n(n) {} in A()
919 constexpr int f() const { return n + 3; } in f()
921 constexpr A a(7);
928 constexpr B(int n, int m) : A(n), m(m) {} in B()
930 constexpr int g() const { return n + m + 1; } in g()
932 constexpr B b(9, 13);
947 constexpr S(int m, int n, int (S::*pf)() const, int S::*pn) : in S()
949 constexpr S() : m(), n(), pf(&S::f), pn(&S::n) {} in S()
951 constexpr int f() const { return this->*pn; } in f()
959 constexpr int S::*pm = &S::m;
960 constexpr int S::*pn = &S::n;
961 constexpr int (S::*pf)() const = &S::f;
962 constexpr int (S::*pg)() const = &S::g;
964 constexpr S s(2, 5, &S::f, &S::m);
988 constexpr int (T<10>::*deepn) = &T<0>::n;
992 constexpr int (T<15>::*deepm) = (int(T<10>::*))&T<30>::m;
993 constexpr int *pbad = &(t17.*deepm); // expected-error {{constant expression}}
998 constexpr T<5> *p17_5 = &t17;
999 constexpr T<13> *p17_13 = (T<13>*)p17_5;
1000 …constexpr T<23> *p17_23 = (T<23>*)p17_13; // expected-error {{constant expression}} expected-note …
1003 constexpr int *pbad2 = &(p17_13->*(int(T<9>::*))deepm); // expected-error {{constant expression}}
1005 constexpr T<5> *p30_5 = &t30;
1006 constexpr T<23> *p30_23 = (T<23>*)p30_5;
1007 constexpr T<13> *p30_13 = p30_23;
1027 constexpr Base() {} in Base()
1031 constexpr Derived() {} in Derived()
1032 constexpr const int *f() const { return &n; } in f()
1035 constexpr Derived a[10];
1036 constexpr Derived *pd3 = const_cast<Derived*>(&a[3]);
1037 constexpr Base *pb3 = const_cast<Derived*>(&a[3]);
1041 constexpr Base *pb4 = pb3 + 1; // ok, one-past-the-end pointer.
1042 …constexpr int pb4n = pb4->n; // expected-error {{constant expression}} expected-note {{cannot acce…
1043 …constexpr Base *err_pb5 = pb3 + 2; // expected-error {{constant expression}} expected-note {{canno…
1044 …constexpr int err_pb5n = err_pb5->n; // expected-error {{constant expression}} expected-note {{ini…
1045 …constexpr Base *err_pb2 = pb3 - 1; // expected-error {{constant expression}} expected-note {{canno…
1046 …constexpr int err_pb2n = err_pb2->n; // expected-error {{constant expression}} expected-note {{ini…
1047 constexpr Base *pb3a = pb4 - 1;
1050 …constexpr Derived *err_pd4 = (Derived*)pb4; // expected-error {{constant expression}} expected-not…
1051 constexpr Derived *pd3a = (Derived*)pb3a;
1052 constexpr int pd3n = pd3a->n;
1055 constexpr Derived *pd6 = pd3a + 3;
1057 constexpr Derived *pd9 = pd6 + 3;
1058 constexpr Derived *pd10 = pd6 + 4;
1059 constexpr int pd9n = pd9->n; // ok
1060 …constexpr int err_pd10n = pd10->n; // expected-error {{constant expression}} expected-note {{canno…
1061 constexpr int pd0n = pd10[-10].n;
1062 …constexpr int err_pdminus1n = pd10[-11].n; // expected-error {{constant expression}} expected-note…
1064 constexpr Base *pb9 = pd9;
1065 constexpr const int *(Base::*pfb)() const =
1075 constexpr complex(int re = 0, int im = 0) : re(re), im(im) {} in complex()
1076 constexpr complex(const complex &o) : re(o.re), im(o.im) {} in complex()
1077 constexpr complex operator-() const { return complex(-re, -im); } in operator -()
1078 friend constexpr complex operator+(const complex &l, const complex &r) { in operator +()
1081 friend constexpr complex operator-(const complex &l, const complex &r) { in operator -()
1084 friend constexpr complex operator*(const complex &l, const complex &r) { in operator *()
1087 friend constexpr bool operator==(const complex &l, const complex &r) { in operator ==()
1090 constexpr bool operator!=(const complex &r) const { in operator !=()
1093 constexpr int real() const { return re; } in real()
1094 constexpr int imag() const { return im; } in imag()
1097 constexpr complex i = complex(0, 1);
1098 constexpr complex k = (3 + 4*i) * (6 - 4*i);
1109 constexpr complex makeComplex(int re, int im) { return complex(re, im); } in makeComplex()
1115 constexpr complex_wrap(int re, int im = 0) : complex(re, im) {} in complex_wrap()
1116 constexpr complex_wrap(const complex_wrap &o) : complex(o) {} in complex_wrap()
1123 constexpr complex_wrap makeComplexWrap(int re, int im) { in makeComplexWrap()
1132 struct A { constexpr bool operator==(int x) const { return true; } }; in operator ==()
1136 …constexpr bool f(int k) { // expected-error {{constexpr function never produces a constant express… in f()
1143 constexpr int get(bool FromA) { return FromA ? A().get() : 1; } in get()
1144 constexpr int n = get(false);
1149 volatile constexpr int n1 = 0; // expected-note {{here}}
1153 constexpr int m1 = n1; // expected-error {{constant expression}} expected-note {{read of volatile-q…
1154 constexpr int m2 = n2; // expected-error {{constant expression}} expected-note {{read of volatile-q…
1155 constexpr int m1b = const_cast<const int&>(n1); // expected-error {{constant expression}} expected-…
1156 constexpr int m2b = const_cast<const int&>(n2); // expected-error {{constant expression}} expected-…
1161 constexpr int f(volatile int &&r) { in f()
1164 constexpr int g(volatile int &&r) { in g()
1177 extern constexpr int n = 0;
1178 extern constexpr int m; // expected-error {{constexpr variable declaration must be a definition}}
1180 … extern constexpr int i; // expected-error {{constexpr variable declaration must be a definition}} in f()
1181 constexpr int j = 0; in f()
1182 constexpr int k; // expected-error {{default initialization of an object of const type}} in f()
1186 constexpr int g() { return q; } in g()
1187 constexpr int q = g();
1191 …constexpr int h() { return r; } // expected-error {{never produces a constant}} expected-note {{re… in h()
1195 constexpr int x() { return s.n; } in x()
1196 constexpr S s = {x()};
1201 constexpr _Complex float test1 = {};
1202 constexpr _Complex float test2 = {1};
1203 constexpr _Complex double test3 = {1,2};
1204 constexpr _Complex int test4 = {4};
1205 constexpr _Complex int test5 = 4;
1206 constexpr _Complex int test6 = {5,6};
1208 constexpr fcomplex test7 = fcomplex();
1210 constexpr const double &t2r = __real test3;
1211 constexpr const double &t2i = __imag test3;
1215 constexpr const double *t2p = &t2r;
1221 constexpr _Complex float *p = 0;
1222 …constexpr float pr = __real *p; // expected-error {{constant expr}} expected-note {{cannot access …
1223 …constexpr float pi = __imag *p; // expected-error {{constant expr}} expected-note {{cannot access …
1224 constexpr const _Complex double *q = &test3 + 1;
1225 …constexpr double qr = __real *q; // expected-error {{constant expr}} expected-note {{cannot access…
1226 …constexpr double qi = __imag *q; // expected-error {{constant expr}} expected-note {{cannot access…
1236 constexpr _Atomic int n = 3;
1239 constexpr S s = { 0.5 };
1240 constexpr double d1 = s.d;
1241 constexpr double d2 = n;
1242 constexpr _Atomic double d3 = n;
1244 constexpr _Atomic(int) n2 = d3;
1251 constexpr TestVar(int value) : value(value) {} in TestVar()
1253 constexpr TestVar testVar{-1};
1259 template<int x> constexpr int f() { return x; } in f()
1268 constexpr int k = 4;
1299 constexpr S(int a, int b, int d, int e) : a(a), b(b), d(d), e(e) {} in S()
1300 constexpr S(int c, int d, int f) : c(c), d(d), f(f) {} in S()
1303 constexpr S s1(1, 2, 3, 4);
1304 constexpr S s2(5, 6, 7);
1327 } constexpr mm = { 4 };
1328 …constexpr int mmn = mm.n; // expected-error {{constant expression}} expected-note {{read of mutabl…
1330 …constexpr int mmn2 = mm.n; // expected-error {{constant expression}} expected-note {{read of mutab…
1335 constexpr MM m = { 0 }; in f()
1343 constexpr C c[3] = {};
1344 constexpr int k = c[1].b.a.n; // expected-error {{constant expression}} expected-note {{mutable}}
1347 constexpr D d1 = { 1, 2 };
1349 …constexpr D d2 = d1; // expected-error {{constant}} expected-note {{mutable}} expected-note {{in c…
1357 constexpr E e1 = {{1}};
1358 …constexpr E e2 = e1; // expected-error {{constant}} expected-note {{mutable}} expected-note {{in c…
1370 constexpr F f1 = {};
1371 constexpr F f2 = f1;
1378 constexpr G g1 = {};
1379 …constexpr G g2 = g1; // expected-error {{constant}} expected-note {{mutable}} expected-note {{in c…
1380 constexpr G::U gu1 = {};
1381 constexpr G::U gu2 = gu1;
1386 constexpr H h1 = {};
1387 …constexpr H h2 = h1; // expected-error {{constant}} expected-note {{mutable}} expected-note {{in c…
1396 …constexpr int n = (int)(char*)123; // expected-error {{constant expression}} expected-note {{reint…
1397 constexpr int m = fold((int)(char*)123); // ok
1406 constexpr const int &f(const int &n) { return n; } in f()
1407 constexpr int k1 = f(0); // ok
1412 constexpr const Wrap &g(const Wrap &w) { return w; } in g()
1413 constexpr int k2 = g({0}).value; // ok
1417 constexpr const int &i = 1;
1418 constexpr const int j = i;
1424 constexpr int &&k = 1; // expected-note {{temporary created here}}
1425 constexpr const int l = k; // expected-error {{constant expression}} expected-note {{read of tempor…
1430 constexpr const int &i = 1; // expected-error {{constant expression}} expected-note 2{{temporary}} in f()
1437 constexpr auto LastNonzero(Iter p, Iter q) -> decltype(+*p) { in LastNonzero()
1441 constexpr int arr1[] = { 1, 0, 0, 3, 0, 2, 0, 4, 0, 0 };
1444 constexpr int arr2[] = { 1, 0, 0, 3, 0, 2, 0, 4, 0, 5 };
1447 constexpr int arr3[] = {
1463 constexpr int n = 1 + in f()
1476 …constexpr int *p = (int*)(int[1]){0}; // expected-warning {{C99}} expected-error {{constant expres…
1481 constexpr VI4 f(int n) { in f()
1484 constexpr auto v1 = f(10);
1487 constexpr VD4 g(int n) { in g()
1490 constexpr auto v2 = g(4);
1504 constexpr int f() { in f()
1513 …struct R { constexpr R() noexcept; constexpr R(const R&) noexcept; constexpr R(R&&) noexcept; ~R()…
1529 friend constexpr U::U() noexcept; // expected-error {{follows non-constexpr}}
1530 friend constexpr U::U(U&&) noexcept; // expected-error {{follows non-constexpr}}
1531 friend constexpr U::U(const U&) noexcept; // expected-error {{follows non-constexpr}}
1539 constexpr Foo id(Foo x) { return x; } in id()
1540 constexpr Foo res(id(Foo()));
1561 constexpr S(int a0) : m(a0) {} in S()
1562 constexpr S() : m(6) {} in S()
1565 constexpr S x[3] = { {4}, 5 };
1576 constexpr A(int a) : v(a) {} in A()
1580 constexpr A f(const A &a) { in f()
1584 constexpr A a(4);
1592 constexpr bool b = &n == &n;
1594 …constexpr int *p = &n; // expected-error{{constexpr variable 'p' must be initialized by a constant…
1596 constexpr int *f() { return &n; } in f()
1597 …constexpr int *q = f(); // expected-error{{constexpr variable 'q' must be initialized by a constan…
1598 constexpr bool c = f() == f();
1600 constexpr int *g() { return &m; } in g()
1601 constexpr int *r = g();
1605 …constexpr void f() { return; } // expected-error{{constexpr function's return type 'void' is not a… in f()
1610 constexpr T get(T (&a)[S], size_t k) { in get()
1615 constexpr int arr[] = { 4, 1, 2, 3, 4 };
1628 constexpr auto &x = typeid(f());
1629 constexpr auto &y = typeid(g()); // expected-error{{constant expression}} \
1636 constexpr duration() {} in duration()
1637 constexpr operator int() const { return 0; } in operator int()
1646 constexpr duration d = duration(); in f()
1657 constexpr A() : p(&p) {} in A()
1660 constexpr A a[10];
1666 constexpr A b[10] = {};
1675 constexpr S f() { return {}; } in f()
1676 constexpr S *p = &f();
1685 constexpr int error() { // expected-error {{no return statement}} in error()
1688 constexpr int k = error(); // expected-error {{must be initialized by a constant expression}}
1700 constexpr initializer_list(const _E* __b, size_t __s) in initializer_list()
1714 constexpr initializer_list() : __begin_(nullptr), __size_(0) {} in initializer_list()
1716 constexpr size_t size() const {return __size_;} in size()
1717 constexpr const _E* begin() const {return __begin_;} in begin()
1718 constexpr const _E* end() const {return __begin_ + __size_;} in end()
1723 constexpr int sum(const int *b, const int *e) { in sum()
1726 constexpr int sum(std::initializer_list<int> ints) { in sum()
1739 constexpr auto a = ({ A(); }); // expected-warning {{extension}} in f()
1741 constexpr int g(int k) { in g()
1748 constexpr int h() { // expected-error {{never produces a constant}} in h()
1764 constexpr X() {} in X()
1766 …constexpr int f() { return sizeof(T); } // expected-warning {{will not be implicitly 'const' in C+… in f()
1770 constexpr X<X<S1>> xxs1;
1771 constexpr X<S1> *p = const_cast<X<X<S1>>*>(&xxs1);
1775 constexpr X<X<S2>> xxs2;
1776 constexpr X<S2> *q = const_cast<X<X<S2>>*>(&xxs2);
1788 constexpr X() noexcept {}; in X()
1792 constexpr X x{};
1797 …constexpr int &n = n; // expected-error {{constant expression}} expected-note {{use of reference o… in f()
1798 …constexpr int m = m; // expected-error {{constant expression}} expected-note {{read of object outs… in f()
1801 constexpr int &get(int &&n) { return n; } in get()
1806 constexpr S() : r(0), s(get(0)), t(r) {} // expected-warning {{temporary}} in S()
1807 …constexpr S(int) : r(0), s(get(0)), t(s) {} // expected-warning {{temporary}} expected-note {{read… in S()
1809 constexpr int k1 = S().t; // ok, int is lifetime-extended to end of constructor
1810 constexpr int k2 = S(0).t; // expected-error {{constant expression}} expected-note {{in call}}
1823 …constexpr A a = { false, 33, 31, false, 0xffffffff, 0x7fffffff }; // expected-warning 2{{truncatio…
1830 constexpr B(int k) : n(k) {} in B()
1842 constexpr static int f(int x) { in f()
1851 constexpr int (*p1)[0] = 0, (*p2)[0] = 0;
1852 constexpr int k = p2 - p1;
1857 constexpr int f() { // expected-error {{never produces a constant expression}} in f()
1874 constexpr B( // expected-error {{must initialize all members}} expected-note {{candidate}} in B()
1885 constexpr int f(int n) { // expected-error {{never produces a constant expression}} in f()
1891 constexpr int n = // expected-error {{must be initialized by a constant expression}}
1899 constexpr int operator()() const { return 0; } in operator ()()
1901 template <typename ...T> constexpr int sink(T ...) { in sink()
1904 template <int ...N> constexpr int run() { in run()
1907 constexpr int k = run<1, 2, 3>();
1911 constexpr const char *a = "foo\0quux";
1912 constexpr char b[] = "foo\0quux";
1913 constexpr int f() { return 'u'; } in f()
1914 constexpr char c[] = { 'f', 'o', 'o', 0, 'q', f(), 'u', 'x', 0 };
1920 constexpr bool check(const char *p) { in check()
1936 …constexpr int over1 = __builtin_strlen(a + 9); // expected-error {{constant expression}} expected-…
1937 …constexpr int over2 = __builtin_strlen(b + 9); // expected-error {{constant expression}} expected-…
1938 …constexpr int over3 = __builtin_strlen(c + 9); // expected-error {{constant expression}} expected-…
1940 …constexpr int under1 = __builtin_strlen(a - 1); // expected-error {{constant expression}} expected…
1941 …constexpr int under2 = __builtin_strlen(b - 1); // expected-error {{constant expression}} expected…
1942 …constexpr int under3 = __builtin_strlen(c - 1); // expected-error {{constant expression}} expected…
1945 constexpr char d[] = { 'f', 'o', 'o' }; // no nul terminator.
1946 …constexpr int bad = __builtin_strlen(d); // expected-error {{constant expression}} expected-note {…
1953 constexpr Test() {} in Test()
1956 void test() { constexpr Test t; } in test()
1971 constexpr E1 e1b(e1);
1972 …constexpr E2 e2b(e2); // expected-error {{constant expression}} expected-note{{read of non-const}}…
1973 constexpr E3 e3b(e3);
1992 …constexpr int Fun() { return; } // expected-error {{non-void constexpr function 'Fun' should retur… in Fun()
1993 …constexpr int Var = Fun(); // expected-error {{constexpr variable 'Var' must be initialized by a c…
1998 …constexpr int f(void); // expected-error{{redefinition of 'f'}} expected-warning{{will not be impl…
2002 template <typename T> constexpr T const &f(T const &x) { return x; } in f()
2006 struct Z : Y { constexpr Z() {} }; in Z()
2008 static constexpr auto z = f(Z());
2014 constexpr A() : x(0), p(&x) {} in A()
2015 constexpr A(const A &a) : x(a.x), p(&x) {} in A()
2017 constexpr A f() { return A(); } in f()
2018 constexpr A g() { return f(); } in g()
2019 constexpr int a = *f().p;
2020 constexpr int b = *g().p;
2025 static constexpr int f(XX*) { return 1; } // expected-note {{here}} in f()
2026 friend constexpr int g(XX*) { return 2; } // expected-note {{here}} in g()
2028 …static constexpr int i = f(static_cast<XX*>(nullptr)); // expected-error {{constexpr variable 'i' …
2029 …static constexpr int j = g(static_cast<XX*>(nullptr)); // expected-error {{constexpr variable 'j' …
2034 struct A { constexpr A(int) {} }; in A()
2037 constexpr B b(0); // expected-error {{constant expression}} expected-note {{derived class}}
2040 constexpr C c(0);
2050 constexpr D d(0); // expected-error {{constant expression}} expected-note {{derived class}}
2057 constexpr E e(0); // expected-error {{constant expression}} expected-note {{derived class}} in f()
2062 struct W { constexpr W(int n) : w(n) {} int w; }; in W()
2066 constexpr Z z(1);