https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
--- Comment #65 from Andrew Church <achurch+gcc at achurch dot org> --- (In reply to Segher Boessenkool from comment #63) > 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! You're confusing two different people with "you" here. Yes, from the compiler's point of view, it's all one translation unit, but on the real-world side, the person who wrote the top-level source file (not using the result) is not the same person who wrote the function declaration (asking to warn when not using the result), and the former has effectively no control over the latter. From the former's point of view, this seems to be to be a reasonable request. (In reply to uecker from comment #64) > I think it is reasonable to want to suppress this using (void). But > [[nodiscard]] does this and I haven't heard any convincing reason why it > could not be used. As one of the advocates for this behavior, it stems (at least in my case) from pre-C23 code in which [[attribute]] syntax was not available. If [[nodiscard]] suppresses the warning, I'd accept that as a solution.