Bug 13083 – using map() with a delegate which uses a ref parameter to the enclosing scope is broken when compiling with -inline (sample code attached)

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-07-09T11:54:00Z
Last change time
2015-07-03T12:53:44Z
Keywords
wrong-code
Assigned to
nobody
Creator
maor

Comments

Comment #0 by maor — 2014-07-09T11:54:14Z
Using dmd 2.065.0 on Linux the following works fine when compiled without -inline but crashes with a segfault when compiled with -inline import std.stdio; int f(ref int[int] hash) { int[] ar = [8, 8, 8, 8]; writefln("result: %s", ar.map!(x => x + hash[x]).reduce!(min)); return 0; } int main() { int[int] hash = [ 8: 1, 9: 2 ]; f(hash); return 0; } reduce is used to force evaluation of the map. the command lines I used are: working: dmd -g ./test.d -oftest broken: dmd -inline -g ./test.d -oftest
Comment #1 by verylonglogin.reg — 2014-09-02T08:03:18Z
Probably duplicates of this one: Issue 13244 & Issue 13286.
Comment #2 by k.hara.pg — 2015-07-03T12:53:44Z
*** This issue has been marked as a duplicate of issue 13244 ***