https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92631
Bug ID: 92631 Summary: Warnings partly caused by system headers are broken Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: mwoehlke.floss at gmail dot com Target Milestone: --- While trying to fix warnings in a code base, we noticed that some are very strange: foo.cpp: warning: by ‘virtual ...’ [-Werror=overloaded-virtual] bar.cpp: warning: but ‘...’ does not throw; perhaps it should be declared ‘noexcept’ [-Wnoexcept] The commonality is that all of these are the second part of a multi-part warning. The first part of the warning IS NOT SHOWN. Further testing proved that the problem isn't on our end (misreading the log or some such); gcc NEVER printed the first part of the warning. Additionally, the file reference for the missing first part would be in a "system" header. Needless to say, this makes for some *very* confusing warnings. Attempting to compile the following example will reproduce the issue: ==> foo.cpp <== #pragma GCC diagnostic error "-Woverloaded-virtual" #include "foo.h" struct bar : foo { void frob(int) override; } ==> foo.h <== #pragma GCC system_header struct foo { virtual void frob(int); virtual void frob(long); }; (Compile with 'g++ foo.cpp'.) Adding -Wsystem-headers "reveals" the missing first part of the warnings/errors. (Apologies if this is a duplicate and I have overlooked a similar report.)