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

            Bug ID: 93979
           Summary: missing context in error message due to inheriting
                    template constructor
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: f.heckenb...@fh-soft.de
  Target Milestone: ---

The following code:

template <typename T> void f (T) = delete;

struct A
{
  template <typename T> A (T v) { f (v); }
};

struct B: A
{
  using A::A;
};

int main ()
{
  B (0);
}

gives this error message:

t.cpp: In instantiation of 'A::A(T) [with T = int]':
t.cpp:10:12:   required from here
t.cpp:5:37: error: use of deleted function 'void f(T) [with T = int]'
t.cpp:1:28: note: declared here

The message itself is correct. However, its context includes 3 locations, but
not the one ultimately causing the problem (here, line 15).

In contrast, "A (0)" instead of "B (0)" gives this location:

t.cpp: In instantiation of 'A::A(T) [with T = int]':
t.cpp:15:7:   required from here
t.cpp:5:37: error: use of deleted function 'void f(T) [with T = int]'
t.cpp:1:28: note: declared here

In my actual code, of course, the function ("f") is only deleted for a few
types of arguments. The function and both structs are declared in some header,
while the offending code (here, in main) is somewhere in some larger source
file and thus hard to find without that location in the message. (Basically
only by a dumb text search for "B" which occurs rather often, so I have to
manually check the arguments in each constructor call to find the bad one.)

Reply via email to