Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 16.9
#1
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;
}
<t></t>
Reply
#2
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.
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)