MISRA Discussion Forums

Full Version: Rule 16.9
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Please consider the following snippet:

Code:
static int foo1(void) {
  return 0;
}

static int foo2(void) {
  return 1;
}

int foo() {
  /* Is the following occurrence of `foo1' compliant wrt 16.9? */
  if (&(foo1) == &foo2)
    return 0;
  return 1;
}
The wording of Rule 16.9 is not precise. The word "preceding" could be interpreted as lexically preceding or semantically preceding. Under the lexical interpretation, the snippet is non-compliant but under the semantic interpretation it is compliant.

The intention of the rule was to prevent a function pointer from being generated when a function call was intended. GIven this, the semantic interpretation is possibly closer to the original intent.