Thread overview
[Issue 923] New: No constant folding for template value default arguments
Feb 02, 2007
d-bugmail
Apr 05, 2007
d-bugmail
[Issue 923] No constant folding for template value default arguments, D1 only
Aug 13, 2009
Don
Oct 21, 2009
Don
February 02, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=923

           Summary: No constant folding for template value default arguments
           Product: D
           Version: 1.004
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: clugdbug@yahoo.com.au


Error: expression 1 + 2 is not a valid template value argument
----------

void a(int b = 1+2)(){};

void main() {
    a!(1+2)();  // OK
    a();        // fails
}


-- 

April 05, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=923





------- Comment #1 from thomas-dloop@kuehne.cn  2007-04-05 11:38 -------
workround: "a!()()" instead of "a()"

Added to DStress as http://dstress.kuehne.cn/run/t/template_58_A.d http://dstress.kuehne.cn/run/t/template_58_B.d http://dstress.kuehne.cn/run/t/template_58_C.d http://dstress.kuehne.cn/run/t/template_58_D.d http://dstress.kuehne.cn/run/t/template_58_E.d


-- 

August 13, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=923


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Summary|No constant folding for     |No constant folding for
                   |template value default      |template value default
                   |arguments                   |arguments, D1 only




--- Comment #2 from Don <clugdbug@yahoo.com.au>  2009-08-13 04:43:06 PDT ---
This has already been fixed in D2. Here's the patch for D1.046. It's trivial.

Index: template.c ===================================================================
--- template.c    (revision 192)
+++ template.c    (working copy)
@@ -3951,6 +3951,7 @@
     {   sinteger_t v;
         real_t r;

+        ea = ea->optimize(WANTvalue | WANTinterpret);
         if (ea->op == TOKvar)
         {
         sa = ((VarExp *)ea)->var;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 21, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=923


Don <clugdbug@yahoo.com.au> changed:

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


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2009-10-21 06:40:11 PDT ---
Fixed DMD1.050.

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