N2338
Nick Stoughton
Error Indicator For Encoding Errors In fgetwc
The Austin Group is currently trying to resolve a defect report against the “fgetwc()” interface, as described in http://austingroupbugs.net/view.php?id=1022 and also http://austingroupbugs.net/view.php?id=1170.
The current wording in N2310 (and N2336) is unchanged from C11, and states in 7.29.3.1p3
If a read error occurs, the error indicator for the stream is set and the fgetwc function returns WEOF. If an encoding error occurs (including too few bytes), the value of the macro EILSEQ is stored in errno and the fgetwc function returns WEOF.
This suggests that if an encoding error occurs the error indicator for the stream is not set (by direct comparison with the previous sentence). However, 7.21.1 states
… an error indicator that records whether a read/write error has occurred …
which would suggest that the error indicator might be set in this case.
The POSIX standard requires that the error indicator be set, but it is not marked as a C extension. The question is: “is it”?
Change 7.29.3.1p3 to require the error indicator to be set in this case:
If a read error occurs, the error indicator for the stream is set and the fgetwc function returns WEOF. If an encoding error occurs (including too few bytes), the error indicator for the stream is set and the value of the macro EILSEQ is stored in errno and the fgetwc function returns WEOF.