1 // Positive examples from N3092 (FCD)
2 // { dg-do compile { target c++11 } }
4 #define SA(X) static_assert(X, #X)
6 constexpr int bufsz = 1024; // OK: definition
9 constexpr int square(int x); // OK: declaration
17 constexpr pixel::pixel(int a) // OK: definition
18 : x(square(a)), y(square(a))
21 constexpr int square(int x) // OK: definition
24 constexpr pixel large(4); // OK: square defined
25 SA(large.x == 16 && large.y==16);
27 constexpr long long_max() // OK
28 { return 2147483647; }
30 SA(long_max() == 2147483647);
32 constexpr int abs(int x) // OK
33 { return x < 0 ? -x : x; }
39 explicit constexpr Length(int i = 0) : val(i) { }
45 constexpr Length l2(12);
50 constexpr pixel2 ur = { 1294, 1024 };// OK
52 SA(ur.x == 1294 && ur.y == 1024);
54 constexpr const int* addr(const int& ir) { return &ir; } // OK
55 static const int x = 5;
56 extern constexpr const int* xp = addr(x); // OK: (const int*)&(const int&)x
57 // is an address contant expression
59 extern constexpr int x2 = *addr(5);