Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
16.9 Reference to function pointer or not
#2
The version without the & operator is certainly a violation of Rule 16.9. The rule requires that any use of an identifier that designates a function (stm_Startup in the example) have a & operator unless the identifier is being used to designate a function in a function call. So, the Tasking tool is correct to diagnose a violation of Rule 16.9.

The version with the & operator is legal C. As described in the C90 standard, Section 6.2.2.1, a function designator is converted to a pointer to function except when it appears as the operand of a sizeof operator or a & operator. Some tools therefore diagnose an & operator applied to an identifier that designates a function because the & operator is redundant in this case. This probably explains why PC-lint issues a diagnostic.

You would need to ask your support contact for PC-lint why it is not diagnosing a violation of Rule 16.9 for the version without the & operator. It might be that the tool needs to be configured differently.
Posted by and on behalf of the MISRA C Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)