AUTOSAR C++14 Rule M27-0-1
The stream input/output library <cstdio> shall not be used
Description
Rule Definition
The stream input/output library <cstdio> shall not be used.
Rationale
Functions in cstdio such as gets,
fgetpos, fopen, ftell,
etc. have unspecified, undefined and implementation-defined behavior.
For instance:
The
getsfunction:does not check if the number of characters provided at the standard input exceeds the bufferchar * gets ( char * buf );
buf. The function can have unexpected behavior when the input exceeds the buffer.The
fopenfunction has implementation-specific behavior related to whether it setserrnoon errors or whether it accepts additional characters following the standard mode specifiers.
Polyspace Implementation
Polyspace® reports a violation of this rule if you use the functions from the
cstdio library. Polyspace detects the use of these cstdio functions:
File operation functions such as
removeandrename.File access functions such as
fclose,fflush, andfopen.Formatted input/output functions such as
fprintf,fscanf,printf, andscanf.Character input output functions such as
fgetc,fgets,fputc, andgetc.Direct input/output functions such as
freadandfwrite.File positioning functions such as
fgetposandfsetpos.Error handling functions such as
clearerr,ferror, andperror.
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: Input/output library |
| Category: Required, Automated |
Version History
Introduced in R2019a