This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16402] g++ -Wmissing-declarations doesn't work
- From: "millerp at canb dot auug dot org dot au" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jul 2004 01:57:12 -0000
- Subject: [Bug c++/16402] g++ -Wmissing-declarations doesn't work
- References: <20040707082444.16402.millerp@canb.auug.org.au>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From millerp at canb dot auug dot org dot au 2004-07-08 01:57 -------
OK, I've read all of 8076 and I think folks have missed the point. You have to
look at it from the point of view of an author who is truly fussy about header
files (if you aren't, you don't turn on this warning).
On the subject of overloading: I realize that overloading is possible in C++.
If I turn this warning on, I'm saying I _want_ to _know_ when my header files
fail to have declarations for ALL my functions (and ALL includes all
overloadings, too). That means I expect that there will be a declaration in
scope for all of the possible overloadings, and I want to know when this isn't
the case. Just to be clear: I want the warning for non-overloaded functions,
too. All means all.
On the subject of code correctness: if there isn't the full set of declaratuions
in scope when an overloading is called, there is the possibility of the compiler
generating a call to the wrong one. It's not the compiler's fault, but the
chances of the user making this mistake is reduced with this warning, because
the compiler can tell the user when there is a definition with no corresponding
declaration, impling that there is no declaration in the header file the caller
is supposed to have included.
>From this perspective -Wmisoverloading and -Wmissing-declarations are synonyms.
On the subject of inline declarations: this is the author saying "both interface
and implementation right here" so I feel that the warning could be legitimately
suppressed for inline declarations (in both gcc and g++).
On the subject of STL: the implementation distributed with libstdc++ is hardly
the poster child for good coding practice, so I'm not convinced by any such
argument (except as a pragmatic transitional issue). BUT this can be solved by
not issuing the warning for system header files, as is done for some other
warnings. This would make the Scott Meyers warnings more useful, too.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16402