summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/constexpr-array21.C
blob: e085098445ab876611f3faf281295c0442936b96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// PR c++/71504
// { dg-do compile { target c++11 } }

typedef const char A4 [10];

constexpr A4 a [] = { "123", "123456", "123456789" };

constexpr int len (const char *s)
{
  return *s ? 1 + len (s + 1) : 0;
}

constexpr const char *s = a[0];
constexpr const char *t = (a + 2)[-2];

constexpr int n0 = len (s);
constexpr int n1 = len (t);

constexpr int n2 = len (a[0]);
constexpr int n3 = len ((a + 2)[-2]);

#define A(e) static_assert ((e), #e)

A (n0 == 3);
A (n0 == n1);
A (n0 == n2);
A (n0 == n3);