This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] ld: optimize vfinfo output slightly

Mike Frysinger <> writes:

> On Friday 30 March 2012 20:30:48 Alan Modra wrote:
>> On Fri, Mar 30, 2012 at 01:20:24PM -0400, Mike Frysinger wrote:
>> > the reason i didn't do that is it causes warnings since fwrite() is
>> > marked as "warn on unused result"
>> (void) fwrite (...);
> that doesn't work either
> $ cat test.c
> #include <stdio.h>
> main(){(void)fwrite("foo", 1, 1, stderr);}
> $ gcc -O2 -Wall test.c -c
> test.c:2:8: warning: ignoring return value of âfwriteâ, declared with 
> attribute warn_unused_result [-Wunused-result]
> assigning it to a variable but not checking the variable no longer works with 
> newer gcc and -Wunused-but-set-parameter

The warn_unused_result attribute in gcc was designed for the realloc
function, where it is truly an error to ignore the result.  It is
absolutely not an error to ignore the result of fwrite; after all, it's
perfectly reasonable to use ferror.  It was a serious misunderstanding
for anybody to attach the warn_unused_result attribute to fwrite.  This
misunderstanding was made even more serious by somebody deciding that it
would be a good idea to have a compiler that defaults to defining

So now we are in an absurd and painful situation, and there is no
consensus on how to get out of it.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]