Thread overview
[Issue 6965] New: [CTFE] wrong reset of variable
Nov 17, 2011
dawg@dawgfoto.de
Nov 18, 2011
Don
Nov 19, 2011
dawg@dawgfoto.de
November 17, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6965

           Summary: [CTFE] wrong reset of variable
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: dawg@dawgfoto.de


--- Comment #0 from dawg@dawgfoto.de 2011-11-17 02:41:56 PST ---
size_t fac(size_t n)
{
    size_t res = n;
    while (n--)
        res *= n;
    return res;
}

static assert(fac(3) == 6);

------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 18, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6965


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |INVALID


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2011-11-18 13:07:40 PST ---
That fails at run time, too. You're multiplying by zero!
Should be:   while(--n)

(In reply to comment #0)
> size_t fac(size_t n)
> {
>     size_t res = n;
>     while (n--)
>         res *= n;
>     return res;
> }
> 
> static assert(fac(3) == 6);
> 
> ------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6965



--- Comment #2 from dawg@dawgfoto.de 2011-11-19 12:07:40 PST ---
Oops.

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