AUTOSAR C++14 Rule A17-1-1
Description
Rule Definition
Use of the C Standard Library shall be encapsulated and isolated.
Rationale
The C Standard Library functions leave the responsibility for handling errors, data races and security issues to developers. For instance, some C Standard Library functions return specific values on errors. A developer calling one of those functions has to explicitly check its return value for those errors.
If all calls to C Standard Library functions are isolated and encapsulated in wrapper functions, the wrapper functions can be left to perform the checking. Callers of those wrapper functions are freed from the responsibility of handling specific error values from the C Standard Library function calls. Instead, the callers can handle errors from the wrapper function calls like any other exception.
Polyspace Implementation
The checker flags functions that contain a call to a C Standard Library function and one of these C++-specific constructs:
A call to a C++ Standard Library function.
A
try
block.A
new
ordelete
operator.Range-based
for
loops.
These C++-specific constructs indicate that the call to the C Standard Library function is not fully encapsulated and isolated. The event list below a rule violation shows the locations of the C Standard Library function call and the C++-specific construct.
Note that when C Standard Library functions are redeclared in the std
namespace, their specifications remain unchanged. The rationale for encapsulating continues
to apply to std::
versions of the C library functions. Therefore, the
checker flags these versions, too.
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: Library introduction |
Category: Required, Non-automated |
Version History
Introduced in R2021a