brintos

brintos / llvm-project-archived public Read only

0
0
Text · 794 B · ebf96ee Raw
34 lines · cpp
1// RUN: %check_clang_tidy %s bugprone-suspicious-memory-comparison %t \2// RUN: -- -- -target i386-unknown-unknown3 4static_assert(sizeof(int *) == sizeof(int));5 6namespace std {7typedef __SIZE_TYPE__ size_t;8int memcmp(const void *lhs, const void *rhs, size_t count);9} // namespace std10 11namespace no_padding_on_32bit {12struct S {13  int x;14  int *y;15};16 17void test() {18  S a, b;19  std::memcmp(&a, &b, sizeof(S));20}21} // namespace no_padding_on_32bit22 23namespace inner_padding {24struct S {25  char x;26  int y;27};28void test() {29  S a, b;30  std::memcmp(&a, &b, sizeof(S));31  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'S' which does not have a unique object representation; consider comparing the members of the object manually32}33} // namespace inner_padding34