Versions Compared

Key

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

...

Improper use of macros may result in undefined behavior.

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

PRE00-C

Medium

Unlikely

Medium

P4

L3

Automated Detection

ToolVersionCheckerDescription
Astrée
Include Page
Astrée_V
Astrée_V

macro-function-like
function-like-macro-expansion

Fully checked
Axivion Bauhaus Suite

Include Page
Axivion Bauhaus Suite_V
Axivion Bauhaus Suite_V

CertC-PRE00
CodeSonar
Include Page
CodeSonar_V
CodeSonar_V

LANG.PREPROC.FUNCMACRO

Function-Like Macro

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

CC2.PRE00

Fully implemented

Helix QAC

Include Page
Helix QAC_V
Helix QAC_V

C3453
Klocwork
Include Page
Klocwork_V
Klocwork_V
MISRA.DEFINE.FUNC
 

LDRA tool suite
Include Page
LDRA_V
LDRA_V

340 S

Enhanced enforcement

Parasoft C/C++test
9.5MISRA2004-19_7Fully implementedPRQA QA-C Include Page
Include Page
Parasoft_V
Parasoft_V
CERT_C-PRE00-a

A function should be used in preference to a function-like macro

PC-lint Plus

Include Page
PC-lint Plus_V
PC-lint Plus_V

9026

Assistance provided

Polyspace Bug Finder

Include Page
Polyspace Bug Finder_V
Polyspace Bug Finder_V

CERT C: Rec. PRE00-CChecks for use of function-like macro instead of function (rec. fully covered)


RuleChecker
Include Page
RuleChecker_V
RuleChecker_V
macro-function-like
function-like-macro-expansion
Fully checked
SonarQube C/C++ Plugin
Include Page
SonarQube C/C++ Plugin_V
SonarQube C/C++ Plugin_V
S960
PRQA QA-C_vPRQA QA-C_v3453Fully implemented

Related Vulnerabilities

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

Related Guidelines

Bibliography

[Dewhurst 2002]Gotcha #26, "#define Pseudofunctions"
[FSF 2005]Section 5.34, "An Inline Function Is as Fast as a Macro"
[Kettlewell 2003]
 

[Summit 2005]Question 10.4

...


...

Image Modified Image Modified Image Modified