http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54311

             Bug #: 54311
           Summary: Info about default template arguments in instantiation
                    backtrace
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: zeratul...@hotmail.com


Consider the following (invalid) code:


template <typename>
class A {};

template <typename T,
          typename U = typename A<T>::type>
class B {};

int main()
{
    B<int> b;
}


GCC's error message is as follows:

test.cpp: In function 'int main()':
test.cpp:10:10: error: no type named 'type' in 'class A<int>'
     B<int> b;
          ^
test.cpp:10:10: error: template argument 2 is invalid
test.cpp:10:13: error: invalid type in declaration before ';' token
     B<int> b;
             ^


Someone looking at this backtrace might be confused as to why A<int> is being
instantiated, as the backtrace doesn't show the line that asks for this
instantiation (that line being "typename U = typename A<T>::type"). The
"template argument 2 is invalid" message provides a hint, but I don't think
it's enough.


I think the error message should be changed to the following:

test.cpp: In function 'int main()':
test.cpp:5:38: error: no type named 'type' in 'class A<int>'
          typename U = typename A<T>::type>
                                      ^
test.cpp:10:10: required from here
     B<int> b;
          ^
test.cpp:10:13: error: invalid type in declaration before ';' token
     B<int> b;
             ^

Reply via email to