Bug 7536 – ctfeAdrOnStack triggered

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-17T20:43:00Z
Last change time
2012-02-20T15:14:05Z
Keywords
CTFE
Assigned to
nobody
Creator
marcianx

Comments

Comment #0 by marcianx — 2012-02-17T20:43:08Z
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 }
Comment #1 by github-bugzilla — 2012-02-20T12:57:59Z
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.
Comment #2 by bugzilla — 2012-02-20T15:14:05Z