[Issue 21756] Immutable array literals cause runtime GC allocation instead of static readonly section allocation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 24 09:10:03 UTC 2021


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

--- Comment #1 from Eyal <eyal at weka.io> ---
I am lacking a way to say the array literal is immutable, so it gets allocated
the same way a string literal does.

This is especially problematic in a function like:

  @nogc string f() {
      enum compileTimeStr = "fmt %x".format(someNum());
      return compileTimeStr; // GC allocation here
  }

--


More information about the Digitalmars-d-bugs mailing list