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

          Issue ID: 22506
           Summary: Accessing immutable AA in @nogc with index results in
                    compilation error
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: muhammed.yu...@bosagora.io

It will throw the following compilation error


  Error: indexing an associative array in `@nogc` function `app.myfunc` may
cause
  a GC allocation


Here is a code example:


  immutable int[int] aa;

  shared static this () 
  {
        aa[10] = 20;
        aa[20] = 30;
  }

  int myfunc () @nogc
  {
        return aa[10];
  }

--

Reply via email to