Bug 24607

Summary: wrong column numbers in diagnostics with templates
Product: gcc Reporter: Ivan Godard <igodard>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: enhancement CC: gcc-bugs, manu, webrown.cpp
Priority: P3 Keywords: diagnostic
Version: 3.4.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2021-08-22 00:00:00

Description Ivan Godard 2005-11-01 05:19:50 UTC
template<typename T> class A{};
template<typename T> class B{};
template<typename T> class C{};
template<typename T> class D{};
template<typename T> class E{};
template<typename T> void f() {
typedef A<typename B<D<E<int> > > > foo;
}


gets you:

~/ootbc/members/src$ g++ foo.cc
foo.cc: In function `void f()':
foo.cc:7: error: template argument 1 is invalid
foo.cc:7: error: ISO C++ forbids declaration of `foo' with no type


In template metaprogramming spaghetti, it would sure help if the diagnostic said just *which* template invocation had argument trouble.

Ivan
Comment 1 Andrew Pinski 2005-11-01 05:31:53 UTC
If we used the caret way of doing things it would just work.
Comment 2 Manuel López-Ibáñez 2011-10-22 14:37:05 UTC
(In reply to comment #1)
> If we used the caret way of doing things it would just work.

It won't work anyway if we don't have the columns right:

GCC 4.7:

pr24607.cc:7:37: error: template argument 1 is invalid      
pr24607.cc:7:42: error: invalid type in declaration before ‘;’ token
Comment 3 Manuel López-Ibáñez 2012-10-14 18:10:19 UTC
Still broken with GCC 4.8:

pr24607.cc:7:37: error: template argument 1 is invalid
   typedef A<typename B<D<E<int> > > > foo;
                                     ^
pr24607.cc:7:42: error: invalid type in declaration before ‘;’ token
   typedef A<typename B<D<E<int> > > > foo;
                                          ^

Clang gets it right:

/tmp/webcompile/_22150_0.cc:7:20: error: expected a qualified name after 'typename'
typedef A<typename B<D<E<int> > > > foo;
                   ^