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

            Bug ID: 79070
           Summary: Unhelpful error message for ambiguous type in template
                    parameter
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gccbugbjorn at fahller dot se
  Target Milestone: ---

Compiling the below program with g++-7 on gcc.godbolt.org and other self
builts, and also older releases of g++:

namespace A {
    class Foo {};
}
namespace B {
    class Foo{};
}

using namespace A;
using namespace B;

template <typename T> using t = T;
using type = t<Foo>;

//Foo* p = nullptr;

gives the unhelpful error message

maggot:/tmp>g++ -std=c++14 c.cpp
c.cpp:13:19: error: template argument 1 is invalid
 using type = t<Foo>;

Removing the comment for the Foo*, gives a considerably more helpful message:

maggot:/tmp>g++ -std=c++14 c.cpp
c.cpp:13:19: error: template argument 1 is invalid
 using type = t<Foo>;
                   ^
c.cpp:15:1: error: reference to 'Foo' is ambiguous
 Foo* p = nullptr;
 ^
c.cpp:6:11: note: candidates are: class B::Foo
     class Foo{};
           ^
c.cpp:3:11: note:                 class A::Foo
     class Foo {};
           ^

Reply via email to