disabling warn_unused_result attribute with FORTIFY_SOURCE?

Kevin Kofler kevin.kofler at chello.at
Thu Mar 15 14:32:44 UTC 2007


Mamoru Tasaka <mtasaka <at> ioa.s.u-tokyo.ac.jp> writes:
> I may be wrong, however, my recognition is that this warning
> cannot be got rid of by casting to void.

You're right, I didn't know that. That's pretty stupid, (void) has always 
meant "I intentionally throw away this value and I mean it". :-/

What works is:
int dummy=foo1();
(void)dummy;
or:
static inline __attribute__((always_inline)) int ignore(int x) {return x;}
ignore(foo1());
but it's annoying you have to go to such lengths. There are always valid 
reasons to ignore a return value. (But don't get me wrong, most often it is NOT 
a good idea to ignore return values. When you're used to programming on 
calculators, where ignoring an error can mean locking up the entire calculator 
on the next instruction and having to press that reset combo once again, you 
quickly learn to always check return values. ;-) You're getting spoiled by high 
quality computer operating systems like Fedora which catch application errors 
properly. ;-) )

        Kevin Kofler




More information about the fedora-devel-list mailing list