[Bug c++/56760] namespaces, templates and forwarding declarations.
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 28 11:05:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56760
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-28 11:05:26 UTC ---
(In reply to comment #8)
> I read the section on name lookup changes at
> http://gcc.gnu.org/gcc-4.7/porting_to.html
>
> but it talks about a different kind of problem. Consider that there the
> compiler does error messages. But here at our problem the linker (!) does the
> error.
It's the same problem. You get a linker error because this line:
func(containHolder, b); // COMMENT THIS OUT AND IT WORKS
calls this function:
template<class T> void func(const seco::contain<T> &a, nam::binbuffer &b)
{ func(*a.wombat, b); }
which then calls this function:
template<class T> void func (const T &a, nam::binbuffer &b);
which is not defined. So you get a linker error.
You are expecting it to call this function:
template<class T> void func(const seco::holder<T> &a, nam::binbuffer &b)
{ func(*a.fun, b); }
but it cannot, because that is not declared before it is used. This is the
situation described in the name lookup changes.
Your code is not valid C++, the compiler is correct.
More information about the Gcc-bugs
mailing list