1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++1y -verify %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc // expected-no-diagnostics
copy(const char * from,unsigned long count,char * to)4*f4a2713aSLionel Sambuc constexpr void copy(const char *from, unsigned long count, char *to) {
5*f4a2713aSLionel Sambuc unsigned long n = (count + 7) / 8;
6*f4a2713aSLionel Sambuc switch(count % 8) {
7*f4a2713aSLionel Sambuc case 0: do { *to++ = *from++;
8*f4a2713aSLionel Sambuc case 7: *to++ = *from++;
9*f4a2713aSLionel Sambuc case 6: *to++ = *from++;
10*f4a2713aSLionel Sambuc case 5: *to++ = *from++;
11*f4a2713aSLionel Sambuc case 4: *to++ = *from++;
12*f4a2713aSLionel Sambuc case 3: *to++ = *from++;
13*f4a2713aSLionel Sambuc case 2: *to++ = *from++;
14*f4a2713aSLionel Sambuc case 1: *to++ = *from++;
15*f4a2713aSLionel Sambuc } while(--n > 0);
16*f4a2713aSLionel Sambuc }
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc
19*f4a2713aSLionel Sambuc struct S {
20*f4a2713aSLionel Sambuc char stuff[14];
SS21*f4a2713aSLionel Sambuc constexpr S() : stuff{} {
22*f4a2713aSLionel Sambuc copy("Hello, world!", 14, stuff);
23*f4a2713aSLionel Sambuc }
24*f4a2713aSLionel Sambuc };
25*f4a2713aSLionel Sambuc
streq(const char * a,const char * b)26*f4a2713aSLionel Sambuc constexpr bool streq(const char *a, const char *b) {
27*f4a2713aSLionel Sambuc while (*a && *a == *b) ++a, ++b;
28*f4a2713aSLionel Sambuc return *a == *b;
29*f4a2713aSLionel Sambuc }
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc static_assert(streq(S().stuff, "Hello, world!"), "should be same");
32*f4a2713aSLionel Sambuc static_assert(!streq(S().stuff, "Something else"), "should be different");
33