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 00:03:02 -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 00:02 -------
This warning remains useful in C++ because if you change the prototype but not
the definition (or vice versa) you get link time errors instead of compile time
warnings.
For example:
Header file reads
void function(int);
and function defintion matches. Everything compiles and links.
Now you decide that the "int" is an old C hangover and you change the
*definition* to
void function(bool)
but you -> forget <- to change the header file. Everything compiles, but the
linker throws an error at every point that "void function(int)" is called,
because it no longer exists.
Ditto for the other way around.
In gcc, you get a compiler warning (or an error in my case, I use -Werror) but
in C++ you get *nothing* until it's time to link. While you do eventually get
an error, I feel that it is _way_ too late in the process. The compiler has all
the information to warn (error) much earlier; gcc does, but g++ doesn't.
I'm not talking about generating the correct code, I'm talking about telling the
user something is wrong as early as the tool chain can possibly do so.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|DUPLICATE |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16402