1// RUN: %check_clang_tidy %s bugprone-suspicious-memory-comparison %t \
2// RUN: -- -- -target i386-unknown-unknown
3
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 std
10
11namespace no_padding_on_32bit {
12struct S {
13 int x;
14 int *y;
15};
16
17void test() {
18 S a, b;
19 std::memcmp(lhs: &a, rhs: &b, count: sizeof(S));
20}
21} // namespace no_padding_on_32bit
22
23namespace inner_padding {
24struct S {
25 char x;
26 int y;
27};
28void test() {
29 S a, b;
30 std::memcmp(lhs: &a, rhs: &b, count: 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 manually
32}
33} // namespace inner_padding
34

source code of clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp