02-10-2026, 12:25 PM
Technically you are right, instantiating the template with n == 1 does lead to a violation for j++. However, we'd say that this code is within the spirit of the rule and it's likely to be too complex and confusing to add exceptions to the rule (and potentially many more) to address specific edge cases.
If this causes a problem with an unexpected violation from a tool, then a deviation is an acceptable work-around (and better that a specialisation for n==1)
If this causes a problem with an unexpected violation from a tool, then a deviation is an acceptable work-around (and better that a specialisation for n==1)
Posted by and on behalf of
the MISRA C++ Working Group
the MISRA C++ Working Group

