AutosarC++17_10-A3.1.4¶
When an array with external linkage is declared, its size shall be stated explicitly
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
Although it is possible to declare an array of incomplete type and access its elements, it is safer to do so when the size of the array can be explicitly determined.
Example
//% $Id: A3-1-4.hpp 271687 2017-03-23 08:57:35Z piotr.tanski $ #include <cstdint> extern std::int32_t array1[]; // Non-compliant extern std::int32_t array2[42]; // Compliant
See Also
- MISRA C++ 2008 [6]: Rule 3-1-3 When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization.
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
unbounded_array |
Array declaration with unknown size. |
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
only_extern¶
only_extern : bool = True
report_arrays_initialized_with_string_literals¶
report_arrays_initialized_with_string_literals : bool = True
report_definitions¶
report_definitions : bool = True