Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 0.1.1 Example f4
#2
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)
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Messages In This Thread
Rule 0.1.1 Example f4 - by cgpzs - 30-09-2026, 12:05 PM
RE: Rule 0.1.1 Example f4 - by misra cpp - 02-10-2026, 12:25 PM
RE: Rule 0.1.1 Example f4 - by misra cpp - 06-10-2026, 10:42 AM
RE: Rule 0.1.1 Example f4 - by cgpzs - 07-10-2026, 11:07 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)