https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90404
--- Comment #3 from David Brown <david at westcontrol dot com> --- Yes, false positives are always a risk with warnings. We already have a warning here that would catch pretty much any case, but with a big risk of false positives - "-Wcast-qual". My hope is for a warning with low risk of false positive, just catching any "you are definitely doing something wrong" cases, which the optimiser has already spotted here. I do understand that sometimes optimiser passes and warning passes are done at different times, so it is not always a matter of "the optimiser sees this, so it should be easy to get a warning". And there is always the caveat that even though a function has clear and unavoidable undefined behaviour (and thus a warning seems appropriate), the compiler might not know that the function will actually be called. (It is fine to have "x / 0" in code that is never run.) But I feel that with -Wall, and certainly with -Wextra, the user is asking the compiler to be generous with warnings, and it should warn on functions that are defined, even if they may not be called.