18-01-2018, 09:16 AM
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
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
the MISRA C++ Working Group