Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 14.2 and system level
#1
As We know, analysis of scope is classified as single translation unit and system.
Rule 14.2 is system analyzed scope,
In my opinion, a For loop is always placed on a function, it is a code block. a loop counter it uses has no linkage.why the analysis for it shall be dependent on the other module, can anybody give a example for explanation?
thanks very much in advance!
<t></t>
#2
Code:
== file1.c ==
void fn ( int32_t *ptr )
{
   *ptr = 10;
}

== file2.c ==
extern void fn ( int32_t *ptr );  /* extern should be in header file */

void loop ( void )
{
  for ( int32_t i = 0; i < 10; i++  )
  {
    fn( &i );
  }
}
The above example is not compliant with rule 14.2 because fn assigns a value to "i" in the body of the loop. This can only be determined if the definition of fn is analysed. Therefore a system analysis containing file1.c and file2.c is required.
Posted by and on behalf of the MISRA C Working Group


Forum Jump:


Users browsing this thread: 1 Guest(s)