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