MISRA Discussion Forums
Rule 19.9 - incorrect comment in mc2_1909.c? - 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 Exemplar Suite (https://forum.misra.org.uk/forumdisplay.php?fid=116)
+--- Thread: Rule 19.9 - incorrect comment in mc2_1909.c? (/showthread.php?tid=508)



Rule 19.9 - incorrect comment in mc2_1909.c? - pkruk - 09-05-2008

mc2_1909.c contains following code:
Code:
#define SUM(A,B,C) ((A) + (B) + (C)) /* Violates Rule 17.4 */

Rule 17.4 is "Array indexing shall be the only allowed form of pointer arithmetic." - the code does not seem to be violation of this rule.


Re: Rule 19.9 - incorrect comment in mc2_1909.c? - misra-c - 21-05-2008

Code:
#define SUM(A,B,C) ((A) + (B) + (C)) /* Violates Rule 17.4 */
The comment above is incorrect. This is a function-like macro which violates rule 19.7.

Code:
mc2_1909_s16a = SUM( 5,
#ifdef SW
                        mc2_1909_s16b,
#else
                        mc2_1909_s16c,
#endif
                        0 );
The above lines should be flagged as a violation of Rule 19.9.