On 10/13/2016 12:32 PM, Ben Burns wrote:
Hello gcc contributors.
I had an issue which was ultimately caused by not using the return
value of a function and I'm trying to find a compile-time warning that
could have alerted me to the issue.
I've been looking through the documentation but I'm not seeing a
compile-time warning flag about ignoring function return values. Sure,
I can add the attribute "warn_unused_result" but I'm wondering if the
same affect is possible (i.e., for all functions) without changing any
code. I feel like this must have come up before and there's a reason
this warning doesn't exist -- perhaps this is better handled by a
static analysis tool, or perhaps it generates too much noise -- but if
there was a previous discussion about this I'd appreciate being
pointed in that direction. Or perhaps I'm just not searching for the
right terms, in which case I apologize for taking your time.
Example below, in which I try a few different compiler warning options
but none of which produce a warning.
There is no flag which will warn on an unused function return value
unless the function has the warn_unused_result attribute.
Jeff