Dear GCC developers,
Would you please consider suppressing (relatively new) warnings like
this one:
ignoring return value of 'int chdir(const char*)', declared with
attribute warn_unused_result
in cases when the source code explicitly casts the result to (void).
Like in
(void) chdir("/");
There is no check necessary in this rare case, yet the compiler
seems to ignore the explicit cast (which tells the developer's
intention exactly: there is nothing to check), and keeps issuing the
warning, regardless.
Making dummy assignment and/or check around such a chdir call (just
to satisfy the "unused result" requirement) will not help make the
code any cleaner.
There are always a subtle number of cases for almost any "__wur"
call that do not need any result consumption. Yet the warning in
general is very helpful in catching the situation where the result is
not consumed *explicitly*.
We're lagging behind the GCC development here and perhaps the newest
version of the compiler does already implement this suggestion -- so
let me apologize for the noise then.
Thanks for considering this suggestion,