Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated link to the corresponding C++ guideline.

...

Code Block
bgColor#ccccff
#define ABS(x) ({int __xtmp = (x); __xtmp < 0 ? -__xtmp : __xtmp; })

Risk Assessment

Defining an unsafe macro leads invocations of the macro with an argument that has side effects, causing those side effects to occur more than once. This can lead to unexpected or undefined program behavior.

...

This rule appears in the C++ Secure Coding Standard as PRE33PRE12-CPP. Never invoke an unsafe macro with arguments containing assignment, increment, decrement, volatile access, or function callDo not define unsafe macros.

References

Wiki Markup
\[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\] Section 5.1.2.3, "Program execution"

...