1 .. title:: clang-tidy - bugprone-suspicious-memory-comparison
3 bugprone-suspicious-memory-comparison
4 =====================================
6 Finds potentially incorrect calls to ``memcmp()`` based on properties of the
7 arguments. The following cases are covered:
9 **Case 1: Non-standard-layout type**
11 Comparing the object representations of non-standard-layout objects may not
12 properly compare the value representations.
14 **Case 2: Types with no unique object representation**
16 Objects with the same value may not have the same object representation.
17 This may be caused by padding or floating-point types.
20 `EXP42-C. Do not compare padding data
21 <https://wiki.sei.cmu.edu/confluence/display/c/EXP42-C.+Do+not+compare+padding+data>`_
23 `FLP37-C. Do not use object representations to compare floating-point values
24 <https://wiki.sei.cmu.edu/confluence/display/c/FLP37-C.+Do+not+use+object+representations+to+compare+floating-point+values>`_
26 This check is also related to and partially overlaps the CERT C++ Coding Standard rules
27 `OOP57-CPP. Prefer special member functions and overloaded operators to C Standard Library functions
28 <https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP57-CPP.+Prefer+special+member+functions+and+overloaded+operators+to+C+Standard+Library+functions>`_
30 `EXP62-CPP. Do not access the bits of an object representation that are not part of the object's value representation
31 <https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP62-CPP.+Do+not+access+the+bits+of+an+object+representation+that+are+not+part+of+the+object%27s+value+representation>`_