Rule 16.7 - 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.7 (/showthread.php?tid=844) |
Rule 16.7 - misterb - 12-09-2011 Hello, please look at the following code snippet: Code: struct testStruct { My compiler returns a MISRA C rule 16.7 checker error because f1() shall point to a const object. In my opinion, it can't be const, because, the object is modified by f2() inside f1(). The compiler can know this. So who is correct? The compiler vendor or me? If the compiler is correct, how can I overcome this problem? If I modify the parameter of f1() to const I'll get an error because f2() modifies the object, the pointer parameter points to. Kind regards, Michael Re: Rule 16.7 - misra-c - 13-09-2011 You are correct and the compiler is wrong. |