------- Comment #8 from redi at gcc dot gnu dot org  2010-03-08 16:18 -------
(In reply to comment #7)
> 
> That's exactly my point!  This is a case where the (function implementation)
> code DOES compile cleanly, but there is an obvious problem that causes it to 
> be
> unusable.

See comment 6

> 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.

> Furthermore, the fact that you can overload functions means that this causes
> even MORE of a problem.  Let's say you have two functions defined:
> int foo(int blue)
> {
>     return 0;
> }
> int foo(long blue)
> {
>     return 1;
> }
> 
> And you decide to call one of them from somewhere else:
> 
> ...
> long somearg = 123;
> int retval = foo(somearg);
> ...
> 
> but you forgot to add the prototype for "int foo(long);".  In this case, all
> the code compiles AND links, but the wrong function is called.

Do you really write overloads that are so similar, and then declare them in
separate headers?
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.


-- 


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

Reply via email to