[Issue 20025] New: alias this combined with a copy constructor seems to lead to undefined behaviour.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jul 4 07:08:35 UTC 2019
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: nobody at puremagic.com
Reporter: big.friendian at gmail.com
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;
}
--
More information about the Digitalmars-d-bugs
mailing list