Bug 15817 – [REG2.068] ICE (with no stacktrace) instead of 'cannot index null array counts' with CTFE AA

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-03-21T07:16:00Z
Last change time
2016-03-22T04:05:19Z
Keywords
CTFE, ice, pull
Assigned to
nobody
Creator
timothee.cour2

Comments

Comment #0 by timothee.cour2 — 2016-03-21T07:16:45Z
dmd -c -o- $bugs_D/bug_D20160320T235820.d $dmd_067_1_X -c -o- $bugs_D/bug_D20160320T235820.d Error: cannot index null array counts called from here: fun("a1.a2 b1.b2") dmd >= 68: (including DMD64 D Compiler v2.070) ICE segmentation fault with no stacktrace => very bad! not sure whether the code should be valid or not, but regardless there shouldn't be ICE, especially wo stacktrace ---- module bugs.bug_D20160320T235820; import std.string; import std.array; int fun(string b){ auto targets=b.split.array; uint[string]counts; foreach(a;targets){ counts[a]++; } return 0; } void fun2(){ enum a=`a1.a2 b1.b2`; static int b=fun(a); } ----
Comment #1 by timothee.cour2 — 2016-03-21T07:38:41Z
update: the problem is the count[a]++; workaround without -version=v_ICE below: // https://issues.dlang.org/show_bug.cgi?id=15817 module bugs.bug_D20160320T235820; import std.string; import std.array; int fun(string b){ auto targets=b.split.array; uint[string]counts; foreach(a;targets){ version(v_ICE){ counts[a]++; } else{ auto ptr=a in counts; if(ptr) *ptr=*ptr+1; else counts[a]=1; } } return 0; } void fun2(){ enum a=`a1.a2 b1.b2`; static int b=fun(a); }
Comment #2 by k.hara.pg — 2016-03-21T15:30:16Z
Dustmited test case: S[] split(S)(S s) { size_t istart; S[] result; foreach (i, c ; s) result ~= s[istart .. i]; return result; } int fun(string b) { auto targets = b.split; uint[string] counts; foreach (a; targets) counts[a]++; return 0; } void fun2() { enum a = `a1`; static b = fun(a); }
Comment #3 by k.hara.pg — 2016-03-21T15:52:36Z
(In reply to Timothee Cour from comment #0) > not sure whether the code should be valid or not, but regardless there > shouldn't be ICE, especially wo stacktrace It was introduced by incomplete fix of issue 9023. The fix for that issue has done in 2.068, but the ICE case didn't tested. https://github.com/D-Programming-Language/dmd/pull/5561
Comment #4 by github-bugzilla — 2016-03-21T18:27:08Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/fd191357c47f33a1bbf061fef13de114ab4d0217 fix Issue 15817 - ICE (with no stacktrace) instead of 'cannot index null array counts' with CTFE AA https://github.com/D-Programming-Language/dmd/commit/db3acaa7aac600e597da66db283e646f1634afcc Merge pull request #5561 from 9rnsr/fix15817 [REG2.068] Issue 15817 - ICE (with no stacktrace) instead of 'cannot index null array counts' with CTFE AA
Comment #5 by github-bugzilla — 2016-03-22T04:05:19Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/fd191357c47f33a1bbf061fef13de114ab4d0217 fix Issue 15817 - ICE (with no stacktrace) instead of 'cannot index null array counts' with CTFE AA https://github.com/D-Programming-Language/dmd/commit/db3acaa7aac600e597da66db283e646f1634afcc Merge pull request #5561 from 9rnsr/fix15817