![]() |
![]() |
1312 | ![]() |
||||
![]() | |||||||
| Declarations and definitions | REFERENCE - ISO:C90-6.5.7 Initialization | ||||||
An array is being initialized with a string literal which is just one byte too long to allow space for the terminating zero byte. This is not illegal. The array will be initialized with the specified characters from the string literal, but be aware that no zero byte will be stored. A string literal always includes a terminating zero byte, and so, "hello" actually consists of 6 bytes. Attempting to initialise an array of type 'char' dimensioned to 5 will result in generation of message 1312. On the other hand if the array were dimensioned to 4, the initialization would be illegal and message 0690 (a constraint error) would be generated. For example:
/*PRQA S 2017,3122,3132,3211,3408,3625 ++*/
char h1[4] = "Hello"; /* Message 0690 - Constraint Error */
char h2[5] = "Hello"; /* Message 1312 */
No MISRA C:2012 Rules applicable to message 1312
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |