a) __attribute__((warn_unused_result)) is non-standard in the first place, are you looking for [[nodiscard]] - GCC does not warn on cast to void with that?
b) A return value that is explicitly marked like this is very different from an unused variable that gp suggested the cast to void idiom for. GCC does not warn on variables that are unused except for a cast to void.
You've defined that function with an attribute saying not to ignore the returned value. Is it right to explicitly silence an explicit warning?
interestingly it works for [[nodiscard]]!
and assigning to std::ignore works for both.
It does work in GCC to suppress unused variable warnings. Just not for function calls I guess.