1 // RUN: %clang_cc1 %s -triple x86_64-unknown-linux -fsyntax-only -verify=c
2 // RUN: %clang_cc1 -x c++ %s -triple x86_64-unknown-linux -fsyntax-only -verify=cxx
3
4 // cxx-no-diagnostics
5
6
7 /// Zero-sized structs should not crash.
b()8 int b() {
9 struct { } a[10];
10 __builtin_memcpy(&a[2], a, 2); // c-warning {{buffer has size 0, but size argument is 2}}
11 return 0;
12 }
13
14 #ifdef __cplusplus
15 // FIXME: This is UB and GCC correctly diagnoses it. Clang should do the same.
b2()16 constexpr int b2() {
17 struct { } a[10];
18 __builtin_memcpy(&a[2], a, 2);
19 return 0;
20 }
21 static_assert(b2() == 0, "");
22 #endif
23