[Issue 13381] One case of array literal that can be stack-allocated
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Aug 31 03:12:33 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13381
--- Comment #3 from yebblies <yebblies at gmail.com> ---
(In reply to bearophile_hugs from comment #2)
>
> One way to rewrite it is (the immutable can't be always used):
>
While re-writes are certainly the simplest way to explain it, using them in the
compiler often leads to complications, especially with error messages referring
to the re-written code instead of the original.
For this case, and similar cases, the compiler can simply type the array
literal as a static array, because it knows that == can't escape any
references. It already does something like this for indexing array literals.
--
More information about the Digitalmars-d-bugs
mailing list