[Bug c/35579] __attribute__(( warn_unused_result )) warns when it shouldn't, doesn't warn when it should

pgut001 at cs dot auckland dot ac dot nz gcc-bugzilla@gcc.gnu.org
Sat Mar 15 09:09:00 GMT 2008



------- Comment #5 from pgut001 at cs dot auckland dot ac dot nz  2008-03-15 09:09 -------
>Care to write a text? I will format it and submit it as a patch if you want.

How about the following, using as a starting point the latest docs (4.3.0),
section 5.27, 'warn_unused_result', which currently ends with:

"...results in warning on line 5.".

Perhaps add to this:

-- Snip --

Note that the warnings are generated by the compiler front-end before any
data-flow analysis is performed, so situations in which the return value is
assigned to a variable but the resulting variable is ignored will not be
detected.  Changing line 5 in the above code to:

  int value = fn();

would result in no warning being emitted even though the return value isn't
used.

-- Snip --

(You could get really pedantic with the wording and say that the caller should
"act on the return value of the function" rather than the somewhat ambiguous
"used", but I think the above should get the meaning across). 

Oh, I also have a feeling that "results in warning on line 5." in the current
docs should really be "results in *a* warning on line 5." :-).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35579



More information about the Gcc-bugs mailing list