The C Standard, subclause 6.7.4 paragraph 3, says:
An inline definition of a function with external linkage shall not contain a definition of a modifiable object with static or thread storage duration, and shall not contain a reference to an identifier with internal linkage.
Noncompliant Code Example
This code refers to a static variable, which has internal linkage, inside an external inline function:
static int I = 12; extern inline void func(int a) { int b = a * I; /* ... */ }
Compliant Solution
This compliant solution does not declare the variable at file scope to be static
and so the variable has external linkage by default.
int I = 12; extern inline void func(int a) { int b = a * I; /* ... */ }
Risk Assessment
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL41-C | Low | Unlikely | Medium | P2 | L3 |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Bibliography
[ISO/IEC 9899:2011] | Subclause 6.7.4, "Function Specifiers" |