| 1 |
// PR c++/106369 |
| 2 |
// { dg-do compile { target c++17 } } |
| 3 |
|
| 4 |
struct A { |
| 5 |
int a[256]; |
| 6 |
constexpr int &operator[] (int n) noexcept { return a[n]; } |
| 7 |
constexpr const int &operator[] (int n) const noexcept { return a[n]; } |
| 8 |
}; |
| 9 |
struct B {}; |
| 10 |
template <typename T> |
| 11 |
struct C { |
| 12 |
constexpr T &foo (const char x) noexcept { c = T::d[x]; return static_cast<T &>(*this); } |
| 13 |
int c; |
| 14 |
}; |
| 15 |
struct D : public C<D>, public B |
| 16 |
{ |
| 17 |
D () noexcept = default; |
| 18 |
static constexpr char e[9] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I' }; |
| 19 |
static constexpr A d = [] () constexpr { |
| 20 |
A f {}; |
| 21 |
for (int i = 0; i < 9; ++i) |
| 22 |
f[e[i]] = 1; |
| 23 |
return f; |
| 24 |
} (); |
| 25 |
}; |
| 26 |
constexpr auto g = D{}.foo ('E'); |