13.5 Loop control expression inconsistencies - 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.13 Control Statement Expressions (https://forum.misra.org.uk/forumdisplay.php?fid=40) +---- Thread: 13.5 Loop control expression inconsistencies (/showthread.php?tid=902) |
13.5 Loop control expression inconsistencies - Dinesh - 30-05-2012 Dear Misra Committee, Going through the previous posts on the rule 13.5, I found an inconsistency between the answers given in: 1) http://www.misra.org.uk/forum/viewtopic.php?f=69&t=272 2) http://www.misra.org.uk/forum/viewtopic.php?f=69&t=874 In the first post, the following was posted: Quote:... In the second post, the following example was given and was confirmed to be compliant with MISRA C 13.5. [code] bool Test_Index(int32_t index, int32_t bound){ return (bool)(p Re: 13.5 Loop control expression inconsistencies - misra-c - 18-06-2012 Firstly, official answers given in this forum are normative. However, as with other standards and guidelines, this does not mean that they are necessarily error-free. As experience is gained with using the guidelines, it may be necessary to post corrections to both the original guidelines and postings in this forum. Your question rightly identifies a discrepancy between two answers given in this forum. The source of the discrepancy is the answer given in 2005 to the posting viewtopic.php?f=69&t=272. In this answer, it was stated that a Loop Counter is the operand of a relational operator in the second expression of the for statement. This should instead have stated that a Loop Counter is involved in the decision to terminate the loop in the second expression of the for statement. This weaker requirement on Loop Counters would then allow i, as used in the response to viewtopic.php?f=69&t=874, to be defined as a Loop Counter provided that the value returned by TestIndex depends its first parameter. |