This is the mail archive of the gcc@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]

Re: 4.1.2 20060928 bug?: undefined overloaded friend function for function pointer


> 
> On Fri, Dec 15, 2006 at 04:24:04PM -0800, Dawser Stevens wrote:
> > The following code can be compiled with every other
> > compiler I have tried (including gcc 4.0 apart from
> > several commercial ones), but, unfortunately, gcc
> > 4.1.2 outputs this:
> > 
> > overload.cpp: In function "int main()":
> > overload.cpp:18: error: no matches converting function
> > "f" to type "void (*)(class A&, const int&)"
> > overload.cpp:4: error: candidates are: void f(A&,
> > const int&)
> > overload.cpp:5: error:                 void f(A&)
> 
> I think the problem is tweaked by the fact that the first declarations
> of the "f" functions are in a friend statement.  If I add
> 
> class A;
> void f(A &a, const int &b);
> void f(A &a);
> 
> before the class, the code compiles.
> 
> The standard compiler on Fedora Core 5 (4.1.1 + patches) also shows
> this problem, yet they built a distro with it, so I think that it's
> not a huge issue.

This is not an issue since this is actually invalid C++ and has already been documented
on http://gcc.gnu.org/gcc-4.1/changes.html:
# ARM-style name-injection of friend declarations is no longer the default. For example:

          struct S {
            friend void f();
          };

          void g() { f(); }

will not be accepted; instead a declaration of f will need to be present outside of the scope of S. The new -ffriend-injection option will enable the old behavior.


Thanks,
Andrew Pinski


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