You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The bug is found in the checker for MISRA C++ 2008 Rule 6–2–2, which states that floating point numbers should not be checked for equality or inequality. The program seems to apply this rule to any floating point comparison, not just floating point equality or inequality checks (i.e. == or !=).
For example, the following snippet of code (with a method that's actually recommended within the MISRA C++ standard to do floating point equality tests) is
boolrelativelyEqual(float a, float b, float epsilon = std::numeric_limits<float>::epsilon())
{
returnstd::abs(a - b) <= epsilon * std::max(std::abs(a), std::abs(b));
}
This is flagged by Analyze as a rule 6-2-2 violation, possibly due to the use of <= symbol. Other simple comparisons such as if (a > 0.0) where a is a float or double also results in a 6-2-2 violation.
To Reproduce
Steps to reproduce the behavior:
Analyze any code with a floating point comparison as stated above
The software will report this as a 6-2-2 violation
Expected behavior
The violation should not be flagged by the software.
Desktop (please complete the following information):
OS: Fedora 40 running Analyze through Podman
Version: latest
The text was updated successfully, but these errors were encountered:
Describe the bug
The bug is found in the checker for MISRA C++ 2008 Rule 6–2–2, which states that floating point numbers should not be checked for equality or inequality. The program seems to apply this rule to any floating point comparison, not just floating point equality or inequality checks (i.e.
==
or!=
).For example, the following snippet of code (with a method that's actually recommended within the MISRA C++ standard to do floating point equality tests) is
This is flagged by Analyze as a rule 6-2-2 violation, possibly due to the use of
<=
symbol. Other simple comparisons such asif (a > 0.0)
wherea
is a float or double also results in a 6-2-2 violation.To Reproduce
Steps to reproduce the behavior:
Expected behavior
The violation should not be flagged by the software.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: