MISRA C++:2023 Rule 11.3.1
Description
Rule Definition
Variables of array type should not be declared. 1
Rationale
The size information of C-style array objects is not always preserved. It is safer to
use containers such as std::array
that preserve the size
information.
As an exception, declaring a const char
array is not a violation
if the array is immediately initialized with a string literal.
Polyspace Implementation
Polyspace® reports a violation of this rule if your code contains a C-style array. Polyspace does not report a violation of this rule when passing a traditional C-style array to a function because arrays decay to pointers when passed to a function as an argument.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Declarators |
Category: Advisory |
Version History
Introduced in R2024b
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.