AutosarC++17_03-A3.9.1¶
Fixed width integer types from <cstdint>, indicating the size and signedness, shall be used in place of the basic numerical types
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
The basic numerical types of char, int, short, long are not supposed to be used,specific-length types from <cstdint> header need be used instead.
Fixed width integer types are:
- std::int8_t
- std::int16_t
- std::int32_t
- std::int64_t
- std::uint8_t
- std::uint16_t
- std::uint32_t
- std::uint64_t
Exceptions
The wchar_t does not need a typedef as it always maps to a type that supports wide characters.
Example
//% $Id: A3-9-1.cpp 271389 2017-03-21 14:41:05Z piotr.tanski $
#include <cstdint>
void f() {
std::int32_t i1 = 5; // Compliant
int i2 = 10; // Non-compliant
std::int64_t i3 = 250; // Compliant
long int i4 = 50; // Non-compliant
std::int8_t i5 = 16; // Compliant
char i6 = 23; // Non-compliant
}
See Also
- MISRA C++ 2008 [6]: Rule 3-9-2 typedefs that indicate size and signedness should be used in place of the basic numerical types.
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
bad_type_alias_name |
Use of badly named type alias for base type. |
None |
False |
missing_integer_typedef |
Fixed width integer types from <cstdint> shall be used. |
None |
False |
wrong_integer_typedef |
Fixed width integer types from <cstdint> shall be used. |
None |
False |
Options¶
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
allow_floating_point¶
allow_floating_point : bool = True
allow_in_user_defined_literals¶
allow_in_user_defined_literals : bool = False
allow_inside_using_declaration¶
allow_inside_using_declaration : bool = False
check_typedef_names¶
check_typedef_names : bool = True
ignore_inherited¶
ignore_inherited : bool = False
treat_plain_char_as_numerical¶
treat_plain_char_as_numerical : bool = True