Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
11.9 and function calls and returned pointers
#1
Could you please clarify to me if this violates 11.9:

Code:
int* f1(void) {
    return 0;  // 11.9 ?
}

And does this violate 11.9:

Code:
void f2(int* ptr);

void f3(void) {
    f2(0);
}

Do you consider returns and function calls to be "assignments" otherwise it seems to me that the Amplification says these are compliant?

The last example in the PDF does suggest that function calls should be considered to be "assignments" however there is no non-compliant example code that I can rely on.

Thank you
Reply
#2
Function returns and setting of function parameters are both assignments, as explained in the MISRA C glossary. Therefore, both of your code snippets are non-compliant with Rule 11.9

Your observation about no non-compliant example is noted.
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)