MISRA Discussion Forums
Clarification for Rule 6.1 - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.6 Types (https://forum.misra.org.uk/forumdisplay.php?fid=33)
+---- Thread: Clarification for Rule 6.1 (/showthread.php?tid=1172)



Clarification for Rule 6.1 - anuj1085 - 06-04-2015

The rule says that the plain char should only be used to store character values.

C standards says single character constant for eg. 'X' are int not char. So the following code:

char x = 'A';

is a violation of the rule as in this char x is storing a constant whose type is "int". If this is not the violation then how to interpret this rule as the all single character constants are int according to "c" standards.


Re: Clarification for Rule 6.1 - misra-c - 23-04-2015

A Technical Corrigendum to MISRA-C:2004 was issued in July 2007. This clarified the status of character constants, by including the sentence.
Quote: Character values/data are character constants or string literals such as 'A', '5', '\n', "a".