23 lines · c
1// RUN: %clang_cc1 %s -triple x86_64-unknown-linux -fsyntax-only -verify=c2// RUN: %clang_cc1 -x c++ %s -triple x86_64-unknown-linux -fsyntax-only -verify=cxx3 4// cxx-no-diagnostics5 6 7/// Zero-sized structs should not crash.8int 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 __cplusplus15// FIXME: This is UB and GCC correctly diagnoses it. Clang should do the same.16constexpr int b2() {17 struct { } a[10];18 __builtin_memcpy(&a[2], a, 2);19 return 0;20}21static_assert(b2() == 0, "");22#endif23