[Issue 13083] New: using map() with a delegate which uses a ref parameter to the enclosing scope is broken when compiling with -inline
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jul 9 04:54:14 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13083
Issue ID: 13083
Summary: using map() with a delegate which uses a ref parameter
to the enclosing scope is broken when compiling with
-inline
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: maor at weka.io
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
--
More information about the Digitalmars-d-bugs
mailing list