https://issues.dlang.org/show_bug.cgi?id=20025
Issue ID: 20025
Summary: alias this combined with a copy constructor seems to
lead to undefined behaviour.
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
Running the following code prints a random integer every time. If the copy
constructor is removed, the code functions as expected (prints '77').
import std.stdio;
struct B
{
static int value = 77;
alias value this;
this(ref return scope inout B rhs) inout { }
}
void test(int x)
{
writefln("x: %s", x);
}
int main()
{
B b;
test(b);
return 0;
}
--