Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Minor edits

C11The C Standard, subclause 6.7.4 (Function Specifiers), p3 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.

...

Code Block
bgColor#ffcccc
langc
static const double C = -0x16c087e80f1e27.0p-62;  /* -0.00138867637746099294692 */

extern inline void func(double a) {
  double b;
  b = a * C;
  /* ... */
}

Compliant Solution

This compliant solution does not declare the constant to be {[static}}.

Code Block
bgColor#ffcccc
langc
const double C = -0x16c087e80f1e27.0p-62;  /* -0.00138867637746099294692 */

extern inline void func(double a) {
  double b;
  b = a * C;
  /* ... */
}

Risk Assessment

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

DCL41-C

Low

Unlikely

Medium

P2

L3

Bibliography

[ISO/IEC 9899:2011]Subclause 6.7.4
-3
, "Function Specifiers"

 

...