This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory

Michael Matz wrote:
> Hi,
> On Tue, 12 Dec 2006, Daniel Jacobowitz wrote:
>> What else do you expect to happen?
> Since you asked ;-) :
> For starters I wouldn't output default args.  I.e. given these decls:
> template <typename T> class X {};
> template <typename T> class Y {};
> template <typename T> class Z {};
> template <typename T, typename H=X<T>, typename I=Y<T>, typename J=Z<T>>
> class A {};
> template <typename T, typename H=A<T>, typename I=A<A<T>>>
> class B {};
> B<int> an_object;
> I wouldn't like to see the type of 'an_object' in the debugger to be shown 
> as (and I cite):
> "B<int,A<int, X<int>, Y<int>, Z<int> >,A<A<int, X<int>, Y<int>,
> Z<int> >, X<A<int, X<int>, Y<int>, Z<int> > >, Y<A<int, X<int>, Y<int>, 
> Z<int> > >, Z<A<int, X<int>, Y<int>, Z<int> > > > >"

One way to solve this is for the debugger to print this as:

  B<#1, A<#1>, A<A<#1> > > with #1 = int

But, I certainly think all the template arguments should be in the debug
information.  For example, it's reasonable for the user to ask for
things like "sizeof (I)" within the scope of B, and it would be nice to
answer that.

The debugging information should be complete; all throttling/formatting
can be done in the debugger.

> Further, I would stop at typedefs.  Given the above decls, and adding 
> this:
> typedef B<float> new_B;
> B<new_B> another_object;

All of the issues you're raising here apply just as well to the
compiler's own error messages.  In general, I'd suggest that we make G++
to do whatever we think best, and then have GDB copy that.  This
particular case is a bit tricky: user's sometimes want to know if
B<typedef_1> and B<typedef_2> are the same type -- and it's not very
easy to see that in the format you suggest.  So, some people argue
strongly for showing typedefs; others argue strongly against it.
Ideally, the debug information would show the typedef, and the debugger
could decide whether to show the typedef name or the type referred to by
the typedef.

Mark Mitchell
(650) 331-3385 x713

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]