Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This code sample also violates guideline INT14-C. Avoid performing bitwise and arithmetic operations on the same data.

...

If the noncompliant form of this test is truly faster, talk to your compiler vendor because, because if these tests are equivalent, optimization should occur. If both forms have the same performance, prefer the portable form.

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Other Languages

Related Guidelines

This rule appears in the C++ Secure Coding Standard as : MSC14-CPP. Do not introduce unnecessary platform dependencies.

Bibliography

Wiki Markup
\[[Dowd 062006|AA. Bibliography#Dowd 06]\] Chapter 6, "C Language Issues" (Arithmetic Boundary Conditions, pp. 211-223)
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 3.4.1, "implementation-defined behavior," Section 3.4.4, "unspecified behavior," Appendix J.1, "Unspecified behavior," and Appendix J.3, "Implementation-defined behavior"
\[[ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] "BQF Unspecified Behaviour"
\[[Seacord 05a2005a|AA. Bibliography#Seacord 05]\] Chapter 5, "Integers"

...