05-02-2021, 04:28 PM
We'd expect the example to be compliant.
In the examples for 6-5-4, the 4th shows 'n' as a non-const variable, and its labelled as 'Compliant if 'n' is not modified within the body of the loop'. So there is an expectation that an analyzer will accept a non-const variable as 'n', and will perform analysis to show that it is not modified. How far that analysis tracks say pointers to n or references to n passed to functions in the loop body is a matter of quality of implementation.
In the examples for 6-5-4, the 4th shows 'n' as a non-const variable, and its labelled as 'Compliant if 'n' is not modified within the body of the loop'. So there is an expectation that an analyzer will accept a non-const variable as 'n', and will perform analysis to show that it is not modified. How far that analysis tracks say pointers to n or references to n passed to functions in the loop body is a matter of quality of implementation.
Posted by and on behalf of
the MISRA C++ Working Group
the MISRA C++ Working Group