digitalmars.D.bugs - [Issue 23182] New: Can't assign struct with opAssign to SumType in
- d-bugmail puremagic.com (42/42) Jun 13 2022 https://issues.dlang.org/show_bug.cgi?id=23182
https://issues.dlang.org/show_bug.cgi?id=23182 Issue ID: 23182 Summary: Can't assign struct with opAssign to SumType in CTFE Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: snarwin+bugzilla gmail.com As of DMD 2.100.0, the following program fails to compile: --- import std.sumtype; struct HasOpAssign { void opAssign(HasOpAssign rhs) {} } SumType!HasOpAssign test() { SumType!HasOpAssign s; s = HasOpAssign(); s = SumType!HasOpAssign(); return s; } void main() { enum result = test(); } --- The error message is --- /usr/include/dmd/druntime/import/core/lifetime.d(2210): Error: `memcpy` cannot be interpreted at compile time, because it has no available source code bug.d(18): compile time context created here --- The cause is calls to core.lifetime.move and core.lifetime.forward in SumType's opAssign overload. Because of issue 21542, these calls cannot be evaluated in CTFE. --
Jun 13 2022