https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
--- Comment #63 from Segher Boessenkool <segher at gcc dot gnu.org> --- (In reply to Christian Groessler from comment #62) > (In reply to Segher Boessenkool from comment #60) > > So you want to not warn for some (just *some*) explicitly unused cases, and > > do > > warn for other explicitly unused cases, and all implicitly unused cases? > > While > > the author of the code explicitly asked for a warning message to be emitted > > in > > all such cases: "The 'warn_unused_result' attribute causes a warning to be > > emitted if a caller of the function with this attribute does not use its > > return > > value." > > Yes! I'm write()ing to a pipe a small amount of data (< page size), and > anyway don't know how to continue if the write() fails. It would be noticed > at the other end. > > (void)write(....) doesn't suppress the warning. Annoying... So you are asking the compiler to warn whenever you do not use the result of a function call, and at the same time you do not use the result of a function call (you merely cast that return value to a different type, but you do not do anything with that). Casting something to a different type is not using it!