This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/43272] -Wmissing-prototypes doesn't work in C++ mode



------- Comment #10 from erh+gcc at nimenees dot com  2010-03-08 16:35 -------
(In reply to comment #8)
> > The code that calls the function also *compiles* cleanly, and only the link
> > fails.
> 
> No, the code calling it does not compile cleanly if there's no previous
> declaration.
> It only compiles cleanly if there's an overload that is similar enough that it
> can be called via conversion.

If you're maintaining existing code there's a good chance that there will be a
similar enough overload.

> Do you really write overloads that are so similar, and then declare them in
> separate headers?

I never said anything about separate headers.  You don't need separate headers,
you just need to be a bit forgetful about what needs to be changed in a single
header.

> Don't do that.  Even ignoring potential ambiguities, it's asking for problems
> if the declarations aren't in a single header.
> 
> But I doubt you really have code like that, so I don't find your argument
> convincing.

Actually, yes I DID have code like that, although it wasn't intended to be that
way.  What happened was that I rewrote a function to use "const char *" instead
of "char *", and forgot to remove the old one.  However, that was a rare
occurrence; most of the cases it's just changing the function signature w/o
many changes to the implementation code.

The case that I keep running into all the time is that I convert a bunch of
code from "char *" from "const char*", then go update the header to match up
with the code, but happen to miss one (or more) prototypes that needed to be
changed.  The code compiles, 
Then sometime later, I (or another developer) build some code that uses the
library, a link error occurs, and we're sitting there scratching our heads
wondering why it's complaining about a function that, at first glance, appears
to exist.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43272


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]