[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
Thu Apr 1 20:14:38 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21756
--- Comment #5 from Eyal <eyal at weka.io> ---
Neither the PR nor this solution seem to resolve the issue. Consider these
pieces of code.
Will NOT compile:
@nogc string f() {
static immutable s = "%5d".format(5);
enum u = s;
return u; // does GC :-(
}
Will compile fine:
@nogc string f() {
static immutable s = "%5d".format(5);
enum u = s ~ "";
return u; // all is well
}
Will also compile fine:
@nogc string f() {
static immutable s = "%5d".format(5) ~ "";
enum u = s;
return u; // all is well
}
Surely this cannot be considered a reasonable state of things?
--
More information about the Digitalmars-d-bugs
mailing list