[Issue 15660] New: result of pure function
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Feb 8 12:58:19 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15660
Issue ID: 15660
Summary: result of pure function
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: iaktakh at gmail.com
Compiler can't determine result of pure function is not unique
import std.stdio;
struct S
{
void[] arr; // with int instead of void program doesn't compiles
auto f() pure @safe
{
int[] a = new int[4];
arr = a;
return a;
}
}
void main() @safe
{
S s;
immutable a = s.f();
int[] b = (cast(int[])s.arr);
writeln(a); // [0, 0, 0, 0]
b[0] = 1;
writeln(a); // [1, 0, 0, 0]
}
--
More information about the Digitalmars-d-bugs
mailing list