MISRA Discussion Forums
Rule 16.9 - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.16 Functions (https://forum.misra.org.uk/forumdisplay.php?fid=47)
+---- Thread: Rule 16.9 (/showthread.php?tid=841)



Rule 16.9 - roberto - 26-08-2011

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;
}



Re: Rule 16.9 - misra-c - 13-09-2011

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.