13-06-2019, 03:15 PM
Both rules address the issue that a value returned by getchar ( and similar functions ) may be indistinguishable from EOF. However they cover different situations.
The description and examples of FIO34-C show that is concerned with the situation when int and char have the same size.
Rule 22.7 is concerned with situations where the return value undergoes a type conversion if that value is then compared to EOF.
The following example is non-compliant with FIO34-C, but compliant with rule 22.7 as no type conversions occur.
The description and examples of FIO34-C show that is concerned with the situation when int and char have the same size.
Rule 22.7 is concerned with situations where the return value undergoes a type conversion if that value is then compared to EOF.
The following example is non-compliant with FIO34-C, but compliant with rule 22.7 as no type conversions occur.
Code:
int c;
do {
c = getchar();
} while (c != EOF);
Posted by and on behalf of the MISRA C Working Group