7536 – ctfeAdrOnStack triggered

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7536 - ctfeAdrOnStack triggered
Summary: ctfeAdrOnStack triggered
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: CTFE
Depends on:
Blocks:
Reported: 2012年02月17日 20:43 UTC by marcianx
Modified: 2012年02月20日 15:14 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description marcianx 2012年02月17日 20:43:08 UTC
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 github-bugzilla 2012年02月20日 12:57:59 UTC
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 Walter Bright 2012年02月20日 15:14:05 UTC
For D1, too. https://github.com/D-Programming-Language/dmd/pull/751 


AltStyle によって変換されたページ (->オリジナル) /