MISRA Discussion Forums
3-9-2 and 'bool' - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19)
+---- Forum: 6.3 Basic concepts (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=132)
+---- Thread: 3-9-2 and 'bool' (/showthread.php?tid=904)



3-9-2 and 'bool' - gs - 12-06-2012

Is rule #3-9-2 intended to apply to the 'bool' type?


Re: 3-9-2 and 'bool' - markturney - 21-11-2014

In section 5. Introduction to the rules, the MISRA C++ 2008 standard specifies that:

"In code fragments, in order to comply with Rule 3–9–2, the following typedef’d types have been assumed... Note that the bool and wchar_t types do not have typedefs.".

All code samples throughout the rest of the standard include the use of bool, so I think it is safe to say that 3-9-2 does not prevent the use of bool.


Re: 3-9-2 and 'bool' - misra cpp - 05-10-2015

3-9-2 does not apply to bool as it is not a "basic numeric type".


Re: 3-9-2 and 'bool' - grunwald - 20-09-2016

Where is the term "basic numerical type" defined?

Does 3-9-2 apply to plain char? The exception "allowing any use of (plain) char to be detected and reported by analysis tools" seems to indicate that analysis tools should report plain char as a 3-9-2 violation; but over in the Misra-C:2012 forum (https://www.misra.org.uk/forum/viewtopic.php?f=240&t=1317) you say that plain char is not a numerical type.


Re: 3-9-2 and 'bool' - misra cpp - 11-10-2016

"basic numerical type" is defined in the first sentence of the rationale of 3-9-2

Currently, this rule does apply to (plain) char, however a future edition will align this rule with that in MISRA C:2012 (Directive 4.6)