Thread overview
templates and debugging problems
Nov 23, 2005
Kris
Jan 25, 2006
Kris
Jan 25, 2006
Sean Kelly
Jan 25, 2006
kris
November 23, 2005
I've often wondered why the debugger could not track the source file for templates, and now I have some insights that might shed some light ~

=======

module A

class ClassTemplate(T)
{
    this () {}
}

alias ClassTemplate!(int) Class;

=======

module B

import A;

void main()
{
    auto GOOD = new Class();

    auto BAD = new ClassTemplate!(long)();
}

=======

So, if the reference is to an alias declared within the same module as the template-source (module A), then the debugger can correctly find its way. In the second case, the debugger thinks the template-source should be within module B instead and gets hoplessly confused.

The workaround for this is provide all possible aliases within module A. That's not practical, and it actually makes the executable notably larger.

Can this be fixed please?


January 25, 2006
This never managed to garner a response, so ...

Apparently the only way to get the debugger to trace into templates is to declare a template alias within the same module as the template itself. Of course, that assumes one can predict beforehand all the various types that might be used with said template.

Worse ~ the compiler instantiates and includes a fully realized template for each alias placed into a template module. And does this for each template module imported. The executable quickly becomes seriously bloated with unused and unwanted code.

Isn't there something that can be done to rectify this?

- Kris



"Kris" <fu@bar.com> wrote in message news:dm2rl1$1vss$1@digitaldaemon.com...
> I've often wondered why the debugger could not track the source file for templates, and now I have some insights that might shed some light ~
>
> =======
>
> module A
>
> class ClassTemplate(T)
> {
>    this () {}
> }
>
> alias ClassTemplate!(int) Class;
>
> =======
>
> module B
>
> import A;
>
> void main()
> {
>    auto GOOD = new Class();
>
>    auto BAD = new ClassTemplate!(long)();
> }
>
> =======
>
> So, if the reference is to an alias declared within the same module as the template-source (module A), then the debugger can correctly find its way. In the second case, the debugger thinks the template-source should be within module B instead and gets hoplessly confused.
>
> The workaround for this is provide all possible aliases within module A. That's not practical, and it actually makes the executable notably larger.
>
> Can this be fixed please?
> 


January 25, 2006
Kris wrote:
> 
> Worse ~ the compiler instantiates and includes a fully realized template for each alias placed into a template module. And does this for each template module imported. The executable quickly becomes seriously bloated with unused and unwanted code.

Even if the template is never instantiated?  This sounds like a bug.


Sean
January 25, 2006
Sean Kelly wrote:
> Even if the template is never instantiated?  

Yep ~ that's what the tests indicate. So there's a bug there that could use fixing.

More importantly, the issue with the debugger needs a fix, so all such aliasing nonsense would become redundant. Let's not forget about the myriad cases where aliasing beforehand is a lost cause. Take containers for example: how does one provide an alias for every concievable type that might be placed within a container? It's silly to contemplate such things :)