www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7536] New: ctfeAdrOnStack triggered

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

           Summary: ctfeAdrOnStack triggered
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: marcianx gmail.com



The code is a simplified version of code that used to work in dmd 2.055. I just
tried it with 2.058 and received
----------
dmd: interpret.c:100: void CtfeStack::setValue(VarDeclaration*, Expression*):
Assertion `v->ctfeAdrOnStack >= 0 && v->ctfeAdrOnStack < stackPointer()'
failed.
----------

import std.conv;

// Create a string that unrolls the given expression N times replacing the
// idx char ('i' by default) with the loop number in the expression each time
string unroll(size_t N, size_t i = 0)(string expr, char idx='i') {
    static if (i < N) {
        string subs_expr;
        foreach (c; expr) {
            if (c==idx) { 
                subs_expr ~= to!string(i); 
            } else {
                subs_expr ~= c;
            }
        }
        return subs_expr ~ "\n" ~ unroll!(N,i+1)(expr,idx);
    }
    return "";
}

struct VectorT(T, int N)
{
    T[N] values_;

    // triggers CTFE error
    bool opEquals(const ref VectorT!(T, N) _rhs) const {
        const string expr = "if(values_[z]!=_rhs.values_[z]) return 0;";
        mixin( unroll!(N)(expr,'z') );
        return 1;
    }
}

void main(string[] args)
{
    alias VectorT!(double,3) Vec3; // triggers CTFE error
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 17 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7536


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr puremagic.com
           Severity|normal                      |regression


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




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/be33306a36507c5d111c292e973569dc2ef5e093
7536 ctfeAdrOnStack triggered

Fix issue 7536 - ctfeAdrOnStack triggered.

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


Walter Bright <bugzilla digitalmars.com> changed:

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



15:14:05 PST ---
For D1, too. https://github.com/D-Programming-Language/dmd/pull/751

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