www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3762] New: Restrictive functionality for template instance recursive expansion

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3762

           Summary: Restrictive functionality for template instance
                    recursive expansion
           Product: D
           Version: 2.039
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: curoles yahoo.com
                CC: curoles yahoo.com



How to reproduce:
template static_factorial(int n)
{
    static if (n == 1)
        const static_factorial = 1;
    else
        const static_factorial = n * static_factorial!(n-1);
}

void main()
{
    writefln("502!=%d", static_factorial!(502));

Error: template instance factorial.static_factorial!(2) recursive expansion

Max recursion depth 500 is hardcoded in template.c function
TemplateInstance::semantic() line 3738 if (++nest > 500). While 500 is
reasonable practical limit, it would be nice to be able to control it somehow,
with #pragma for example.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3762




 While 500 is reasonable practical limit, it would be nice to be able to 
control it somehow, with #pragma for example. Do you have ANY use cases for this? The limit is (a) to prevent the compiler from crashing with a stack fault; and (b) to warn the user when they have inadvertently created an infinite loop. By the way, on DMD, the limit couldn't be set much higher. It blows the stack at about 700. If there were a pragma, its only effect would be to create an error message stating that the limit cannot be increased above 500. I just don't believe that it is 'restrictive' in any meaningful sense. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 04 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3762




No, I do not have any real use case for this. I have to admit that after all it
is not that restrictive.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 04 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3762


Igor Lesik <curoles yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 04 2010