Comment 5 for bug 305176

Revision history for this message
In , Pinskia (pinskia) wrote :

Actually it is documented that this is acting the way it is acting, just not with the docs of the attributes:
Warning when a non-void function value is ignored.
C contains many standard functions that return a value that most programs choose to ignore. One obvious example is printf. Warning about this practice only leads the defensive programmer to clutter programs with dozens of casts to void. Such casts are required so frequently that they become visual noise. Writing those casts becomes so automatic that they no longer convey useful information about the intentions of the programmer. For functions where the return value should never be ignored, use the warn_unused_result function attribute (see Function Attributes).

"should never" means it cannot be the result cannot be ignored at all (well assigning to a variable and ignoring that is a work around).

As shown this is not a GCC bug as GCC is acting as documented.

The reason why it is a glibc bug is that it is very over the top of adding the attribute here.