3-9-2 and 'bool'

Moderators: david ward, misra cpp

gs
Posts: 87
Joined: Thu Nov 18, 2004 1:39 am

3-9-2 and 'bool'

Postby gs » Tue Jun 12, 2012 3:23 pm

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

markturney
Posts: 2
Joined: Thu Nov 20, 2014 5:58 pm
Company: Energid

Re: 3-9-2 and 'bool'

Postby markturney » Fri Nov 21, 2014 2:23 pm

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.

misra cpp
Posts: 145
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: 3-9-2 and 'bool'

Postby misra cpp » Mon Oct 05, 2015 2:40 pm

3-9-2 does not apply to bool as it is not a "basic numeric type".
Posted by and on behalf of
the MISRA C++ Working Group

grunwald
Posts: 12
Joined: Wed May 14, 2014 1:02 pm
Company: Axivion GmbH

Re: 3-9-2 and 'bool'

Postby grunwald » Tue Sep 20, 2016 1:55 pm

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.

misra cpp
Posts: 145
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: 3-9-2 and 'bool'

Postby misra cpp » Tue Oct 11, 2016 10:17 am

"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)
Posted by and on behalf of
the MISRA C++ Working Group


Return to “6.3 Basic concepts (C++)”

Who is online

Users browsing this forum: No registered users and 3 guests