On Thu, Nov 22, 2012 at 11:32 AM, Craig A. Berry <craig.a.berry@gmail.com> wrote: > On Wed, Nov 21, 2012 at 3:26 PM, Karl Williamson > <public@khwilliamson.com> wrote: >> On 11/21/2012 12:11 PM, Craig A. Berry wrote: > > >>> I agree. Which compiler? >> >> >> gcc version 4.4.5. > > Apparently this doesn't derive from the use of -Wunused-result but > from the attribute with which the function is declared. Expanding on > the stackoverflow article at > <http://stackoverflow.com/questions/2870529/g-how-to-get-warning-on-ignoring-function-return-value>, > you can see from my example at the end of this message that: > > 1.) -Wunused-result is on by default, but you can turn it off with > -Wno-unused-result. > 2.) It does not affect functions declared with a return value unless > they also have the warn_unused_result attribute. In other words, it > does absolutely nothing for the common case where someone creates a > function that returns a value but forgets to check that value. > 3.) As we've already seen the attribute trumps casting to void. > > Since we don't have control over the attributes of the functions in > libc, I think the choices are to either turn off the warning or use > one of the workarounds posted in this thread. Or live with the > eyeball strain of ignoring the useless warnings, which makes it > tempting to ignore all warnings, as if people needed an incentive for > that. > Reviving this older thread, with a patch to apply one of the workarounds. Or if someone wants to apply a different workaround, I'm not picky :-)Thread Previous | Thread Next