diff options
Diffstat (limited to 'clang/test/SemaCXX/constant-expression-cxx11.cpp')
-rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx11.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp index af0d5f3e1c3..995cd2ffece 100644 --- a/clang/test/SemaCXX/constant-expression-cxx11.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp @@ -391,6 +391,20 @@ struct S { int n : "foo"[4]; // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}} }; +struct T { + char c[6]; + constexpr T() : c{"foo"} {} +}; +constexpr T t; + +static_assert(t.c[0] == 'f', ""); +static_assert(t.c[1] == 'o', ""); +static_assert(t.c[2] == 'o', ""); +static_assert(t.c[3] == 0, ""); +static_assert(t.c[4] == 0, ""); +static_assert(t.c[5] == 0, ""); +static_assert(t.c[6] == 0, ""); // expected-error {{constant expression}} expected-note {{one-past-the-end}} + } namespace Array { |