Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 8-5-2: what about strings?
#3
You are correct that the example initializing using "Hello" etc. is a violation of 8-5-2 (and dg1980's example padded with '\0's is compliant). However, the first example would be compliant under MISRA C:2012 - it has the exception for strings.

The next issue of MISRA C++ aims to remove unnecessary differences between MISRA C and C++, and this is likely to be a rule that will be modified for that reason - though they may still not be identical because there is a semantic difference between C and C++ for a statement like
char str[4] = "abcd";
(its legal in C but a constraint error in C++)


As a matter of etiquette, we don't encourage discussion of particular tool's behaviour on the Bulleting Board - good or bad
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)