This is the mail archive of the binutils@sourceware.org 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] | |
On Saturday 31 March 2012 00:59:32 Ian Lance Taylor wrote:
> 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
> _FORTIFY_SOURCE.
while i agree with not using wur on fwrite, i obviously disagree with fortify-
by-default being a bad thing. it has caught plenty of real bugs with little
overhead.
-mike
Attachment:
signature.asc
Description: This is a digitally signed message part.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |