AutosarC++18_03-M19.3.1

The error indicator errno shall not be used

Required inputs: IR

Rationale

errno is a facility of C++ which should in theory be useful, but which in practice is poorly defined by ISO/IEC 14882:2003. A non-zero value may or may not indicate that a problem has occurred; therefore errno shall not be used.

Even for those functions for which the behaviour of errno is well defined, it is preferable to check the values of inputs before calling the function rather than relying on using errno to trap errors.

Example
#include <cstdlib> 
#include <cerrno>
void f1 ( const char_t * str )
{
errno = 0; // Non-compliant
int32_t i = atoi ( str ); if ( 0 != errno ) // Non-compliant
{
// handle error case???
}
}
See also

Rule 0.3.2

Note

For legal reasons, this rule’s description is not part of the public documentation.