brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 317f8e1 Raw
36 lines · plain
1.. title:: clang-tidy - bugprone-suspicious-memory-comparison2 3bugprone-suspicious-memory-comparison4=====================================5 6Finds potentially incorrect calls to ``memcmp()`` based on properties of the7arguments. The following cases are covered:8 9**Case 1: Non-standard-layout type**10 11Comparing the object representations of non-standard-layout objects may not12properly compare the value representations.13 14**Case 2: Types with no unique object representation**15 16Objects with the same value may not have the same object representation.17This may be caused by padding or floating-point types.18 19See also:20`EXP42-C. Do not compare padding data21<https://wiki.sei.cmu.edu/confluence/display/c/EXP42-C.+Do+not+compare+padding+data>`_22and23`FLP37-C. Do not use object representations to compare floating-point values24<https://wiki.sei.cmu.edu/confluence/display/c/FLP37-C.+Do+not+use+object+representations+to+compare+floating-point+values>`_25 26This check is also related to and partially overlaps the CERT C++ Coding Standard rules27`OOP57-CPP. Prefer special member functions and overloaded operators to28C Standard Library functions29<https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP57-CPP.+Prefer+special+member+functions+and+overloaded+operators+to+C+Standard+Library+functions>`_30and31`EXP62-CPP. Do not access the bits of an object representation that are not32part of the object's value representation33<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>`_34 35`cert-exp42-c` redirects here as an alias of this check.36