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++/78724] New: Incorrect ambiguous reference error when templace class was forward declarated as a friend


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78724

            Bug ID: 78724
           Summary: Incorrect ambiguous reference error when templace
                    class was forward declarated as a friend
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: loic.yhuel at gmail dot com
  Target Milestone: ---

namespace A {
    template<class>
    class B {
        template<class> friend class C;
    };
}

void foo()
{
    A::B<void> b;
}

namespace A {
    template<class>
    class C {
    };
}

using namespace A;

void bar()
{
    C<void> c;
}

=>
test.cpp: In function ‘void bar()’:
hello.cpp:23:5: error: reference to ‘C’ is ambiguous
     C<void> c;
     ^
test.cpp:4:38: note: candidates are: template<class> class A::C
         template<class> friend class C;
                                      ^
hello.cpp:15:11: note:                 template<class> class A::C
     class C {
           ^

Note that the error doesn't happen when using "A::C<void> c".


The bug is seen with libc++ 3.9.0 headers :
#include <map>
void foo()
{
    std::map<void*,void*>::iterator it;
}
#include <set>
using namespace std;
void bar()
{
    set<void*> s;
}

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