Bug 14299 – [REG2.067.0-rc1] "ref" parameter in CTFE handled incorrectly for recursive calls

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-03-17T08:31:00Z
Last change time
2015-06-17T21:02:26Z
Keywords
ice, pull, wrong-code
Assigned to
nobody
Creator
sludwig

Comments

Comment #0 by sludwig — 2015-03-17T08:31:59Z
The following code works correctly in DMD 2.066.1: ``` string test2() { string n; return test(0, n); } string test(int idx, ref string name) { string ret; name = [cast(char)(idx + '0')]; ret ~= name; if (idx < 2) { string subname; ret ~= test(idx+1, subname); } ret ~= name; return ret; } static assert(test2() == "012210"); ``` On DMD 2.067-rc1 it fails with: Assertion failure: 'v->ctfeAdrOnStack >= 0 && v->ctfeAdrOnStack < stackPointer() ' on line 182 in file 'interpret.c' In the original, more complex, scenario instead of an ICE, the "name" variable was silently corrupted instead and contained the contents of "subname" after the recursive call to test().
Comment #1 by k.hara.pg — 2015-03-17T14:33:20Z
Comment #2 by github-bugzilla — 2015-03-18T03:59:03Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/8980914a5f101c18e7b05d071d511f5cdd3098bf fix Issue 14299 - "ref" parameter in CTFE handled incorrectly for recursive calls https://github.com/D-Programming-Language/dmd/commit/229edba461ef6f6e2254e060eb498f302e982563 Merge pull request #4501 from 9rnsr/fix14299 [REG2.067a] Issue 14299 - "ref" parameter in CTFE handled incorrectly for recursive calls
Comment #3 by github-bugzilla — 2015-03-18T19:44:42Z
Commit pushed to 2.067 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/3d8ba6346e92938301c7da036b22f9eb613e3a62 Merge pull request #4501 from 9rnsr/fix14299 [REG2.067a] Issue 14299 - "ref" parameter in CTFE handled incorrectly for recursive calls
Comment #4 by github-bugzilla — 2015-04-11T12:25:05Z
Comment #5 by github-bugzilla — 2015-06-17T21:02:26Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/8980914a5f101c18e7b05d071d511f5cdd3098bf fix Issue 14299 - "ref" parameter in CTFE handled incorrectly for recursive calls https://github.com/D-Programming-Language/dmd/commit/229edba461ef6f6e2254e060eb498f302e982563 Merge pull request #4501 from 9rnsr/fix14299