[Issue 7536] New: ctfeAdrOnStack triggered

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 17 20:43:09 PST 2012


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 at puremagic.com
        ReportedBy: marcianx at gmail.com


--- Comment #0 from marcianx at gmail.com 2012-02-17 20:43:08 PST ---
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: -------


More information about the Digitalmars-d-bugs mailing list