Bug 24607 - wrong column numbers in diagnostics with templates
Summary: wrong column numbers in diagnostics with templates
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2005-11-01 05:19 UTC by Ivan Godard
Modified: 2021-08-23 11:49 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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;
                   ^