...
The most severe problem with unsafe function-like macros is side effects of macro arguments, as shown in this noncompliant code example.:
Code Block | ||||
---|---|---|---|---|
| ||||
#define ABS(x) (((x) < 0) ? -(x) : (x)) void f(int n) { int m; m = ABS(++n); /* ... */ } |
The invocation of the ABS()
macro in this noncompliant code example expands to the following code. The resulting code has well-defined behavior , but causes n
to be incremented twice rather than once, which may be surprising to those unfamiliar with the implementation of the macro or unaware that they are using a macro in the first place.
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
| macrbody | Fully implemented. |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...