[Issue 23170] New: Array literal passed to map in lambda, then returned from nested function, is memory corrupted

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 7 15:37:35 UTC 2022


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

          Issue ID: 23170
           Summary: Array literal passed to map in lambda, then returned
                    from nested function, is memory corrupted
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: default_357-line at yahoo.de

Consider this code:

import std.algorithm;
import std.conv;
import std.range;

void main()
{
    auto result = ({ return [1, 2, 3].badMap; })().array;

    assert(result == [1, 2, 3], result.to!string);
}

alias badMap = range => range.map!(a => a);

Expected: No output.

Actual output: core.exception.AssertError at foo.d(9): [1, 2, 623040144]

(Numbers vary semi-randomly.)

Works on DMD 2.091.1.
Crashes on 2.092.0, 2.097, 2.099 and 2.100. (Thanks ndf!)

--


More information about the Digitalmars-d-bugs mailing list