2ae67eac523c93cff20407b3aa910835119c7dba
[platform/upstream/llvm.git] / clang-tools-extra / docs / clang-tidy / checks / bugprone-suspicious-memory-comparison.rst
1 .. title:: clang-tidy - bugprone-suspicious-memory-comparison
2
3 bugprone-suspicious-memory-comparison
4 =====================================
5
6 Finds potentially incorrect calls to ``memcmp()`` based on properties of the
7 arguments. The following cases are covered:
8
9 **Case 1: Non-standard-layout type**
10
11 Comparing the object representations of non-standard-layout objects may not
12 properly compare the value representations.
13
14 **Case 2: Types with no unique object representation**
15
16 Objects with the same value may not have the same object representation.
17 This may be caused by padding or floating-point types.
18
19 See also: 
20 `EXP42-C. Do not compare padding data
21 <https://wiki.sei.cmu.edu/confluence/display/c/EXP42-C.+Do+not+compare+padding+data>`_
22 and
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>`_
25
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>`_
29 and
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>`_