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); } ----
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); }
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); }
(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
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
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