[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#626983: ferror(): return no error when the stream is closed



reassign 626983 manpages-dev 3.27-1
# documentation
severity 626983 minor
retitle 626983 fclose.3: please clarify stream state after fclose
quit

Hi,

julien godin wrote:

> As described in the subject, the ferror() function return no error even if
> the stream as been previously closed

As the POSIX[1] documentation for fclose() says:

	After the call to fclose(), any use of stream results in undefined
	behavior.

Similarly, C99[2] says

	The value of a pointer to a FILE object is indeterminate after the
	associated file is closed.

which is earlier defined to mean

	either an unspecified value or a trap representation

If you'd like that last behavior ("trap representation") in order to
catch bugs, valgrind can help.

I'm reassigning to manpages-dev in the hope that the system
documentation for ferror and fclose can be improved to clarify this.
I imagine help with wording would be very welcome.

Thanks for reporting,
Jonathan

[1] http://unix.org/2008edition/ (free registration required)
[2] http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899



Reply to: