[Bug c++/16402] g++ -Wmissing-declarations doesn't work
bangerth at dealii dot org
gcc-bugzilla@gcc.gnu.org
Wed Jul 7 13:04:00 GMT 2004
------- Additional Comments From bangerth at dealii dot org 2004-07-07 13:03 -------
The reasoning we don't have this option in c++ is the following: in C, it
is potentially harmful if you define a function, but do not provide a
prototype declaration in a header file, since you can call this function
without a prototype in another .c file with incompatible arguments. Example:
a.c:
int f(int i) {}
b.c:
void g() {
f(1.1);
}
This is legal, and passes a double value to f(), which will of course
yield 'interesting' results. The warning you cite reminds you that you better
have a declaration of a prototype in one of your header files, which then
should be included into b.c.
This reasoning doesn't work in C++: the call to f(1.1) is invalid code, unless
you provide a prototype. You get an error. There is no potential for mistakes
here, which is why the warning was never implemented.
I can see a few cases where the warning would make some sense, but you could
make a stronger case for your request if you could provide an explanation
why this option would be useful to have in C++ as well, rather than only in C.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16402
More information about the Gcc-bugs
mailing list