https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
--- Comment #45 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Church from comment #44) > (In reply to Segher Boessenkool from comment #43) > > That is not the consensus, no. "Consensus" does not mean doing what the > > unthinking masses shout. > > Merriam-Webster disagrees: > con.sen.sus > 1 a: general agreement : UNANIMITY > b: the judgment arrived at by most of those concerned But there is no general agreement at all. If clang behavior agreed with gcc, then there would be consensus here. In fact gcc behavior is older than clang behavior makes this even more difficult and even points out that if clang said it implemented a compatible extension, it did not. > > I specifically clarified that with "wider" to indicate the larger group of > "C compiler users", as opposed to what you seem to mean, "C compiler > developers". And in whatever sense you choose to regard them, the judgment > arrived at by most C compiler users does seem to be "cast to void should > suppress a warning about a discarded value", as I described above. > There is still no general consensus really. Just that the folks who want behavior difference is loud while the ones who are happy with the current behavior are quiet because they don't need to tell their thoughts on it. > > So allowing casts to void > > to suppress this warning means the warning becomes less useful, and people > > will write worse code. That is not something GCC should encourage IMO. > > You seem to think that making the warning harder to work around will > encourage programmers to change their code to fix the warning. In reality, > they are more likely to either (1) disable the warning entirely or (2) > disregard warnings in general, both of which result in considerably worse > code - the situation you say you are trying to avoid. Thus my suggestion to > follow the principle of least surprise and allow a void cast to disable the > warning by default. You are basically saying all warnings will be ignored which is true. Even ones with no false positives are ignored. Using a void cast makes life too easy to ignore this behavior. If the api user wants to ignore the return values while the api developer tells you should not, then really the api user will have bugs. This is why the warning is there. Now api developers have known to place this attribute on things that should not be placed on but that is not a compiler issue and the api user should talk with the api developer rather than try to change the compiler for their workaround.