------- Comment #6 from joseph at codesourcery dot com 2005-12-21 03:55 ------- Subject: Re: can't voidify __attribute__((warn_unused_result))
On Wed, 21 Dec 2005, pinskia at gcc dot gnu dot org wrote: > The reason why it is a glibc bug is that it is very over the top of adding the > attribute here. And indeed there is no logical difference between printf and fwrite here, but glibc is marking fwrite and not printf. In both cases, a valid programming style is to use fflush and ferror at the end to check for errors, rather than checking on every write, or to check the return value of fclose. A program that uses fwrite without checking the return value or such a subsequent error is buggy - so is one using printf and failing later to check for errors on stdout. (GCC is among such buggy programs; "gcc --help >/dev/full" does not return error status as it should.) But checking at the end suffices (albeit losing information about the value of errno for the original error), you don't need to check at every call. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509