disabling warn_unused_result attribute with FORTIFY_SOURCE?

Mamoru Tasaka mtasaka at ioa.s.u-tokyo.ac.jp
Thu Mar 15 04:33:29 UTC 2007


Kevin Kofler wrote:
> Matthew Miller <mattdm <at> mattdm.org> writes:
>> Unlike other warnings, though, there doesn't seem to be a way to turn it
>> off. Is there one I'm missing?
> 
> The _easy_ way to get rid of the warnings is to cast the unused results to 
> void.

I may be wrong, however, my recognition is that this warning
cannot be got rid of by casting to void.
-----------------------------------------
[tasaka1 at localhost TEMP]$ cat attri_unused.c

int foo1(){
   return 2;
}

int foo1 () __attribute__ ((warn_unused_result));

int main(){
   (void) foo1();
   return 0;
}
[tasaka1 at localhost TEMP]$ LANG=C gcc -o attri_unused attri_unused.c -Wp,-D_FORTIFY_SOURCE=2
attri_unused.c: In function 'main':
attri_unused.c:9: warning: ignoring return value of 'foo1', declared with attribute 
warn_unused_result
-----------------------------------------




More information about the fedora-devel-list mailing list