https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |jason at gcc dot gnu.org --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The wording could be improved, but why do you think the warning is spurious? While the method isn't static, it is effectively static, because it is internal linkage (i.e. visibility constrained to the current TU in which it is not really defined). If you ask for -Wunused-function, you get it if the compiler can figure it out. The reason it doesn't warn at -O0 is that it doesn't see it unless it tries to devirtualize. Not sure if we have a way to find out if !TREE_PUBLIC is because it has been declared static or because it has internal linkage and constrain_visibility VISIBILITY_ANON has been called on it (and would need a langhook anyway to determine that).