[Issue 15817] ICE (with no stacktrace) instead of 'cannot index null array counts' with CTFE AA

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Mar 21 00:38:41 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15817

Timothee Cour <timothee.cour2 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timothee.cour2 at gmail.com

--- Comment #1 from Timothee Cour <timothee.cour2 at gmail.com> ---
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);
}

--


More information about the Digitalmars-d-bugs mailing list