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

            Bug ID: 63392
           Summary: poor error recovery with missing typename
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manu at gcc dot gnu.org

template<typename T>
class A {
  A(int i) : x(i) {}
  T::type x;
};

$ g++ test.cc
test.cc:4:3: error: need ‘typename’ before ‘T::type’ because ‘T’ is a dependent
scope
   T::type x;
   ^
 A<T>::A(int)
test.cc:3:14: error: class ‘A<T>’ does not have any field named ‘x’
   A(int i) : x(i) {}
              ^
$ clang++ test.cc
test.cc:4:3: error: missing 'typename' prior to dependent type name 'T::type'
  T::type x;
  ^~~~~~~
  typename


Of course it gets worse in the case of GCC if x is used later in the code.

Reply via email to