[Issue 20719] Self referential struct definition causes stack overflow
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 14 19:41:27 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20719
--- Comment #1 from Ben <ben.james.jones at gmail.com> ---
Reduced test case:
import std.meta : AliasSeq;
import std.typecons : ReplaceTypeUnless;
import std.traits : isCopyable, isAssignable;
struct This; //defined in std.variant this way
struct SumType(TypeArgs)
{
alias Types = AliasSeq!(ReplaceTypeUnless!(isSumType, This, typeof(this),
TypeArgs));
union Storage
{
template memberName(T)
{
mixin("enum memberName = `values_", "`;");
}
static foreach (T; Types)
mixin("T ", memberName!T, ";");
}
Storage storage;
static foreach (T; Types) static if (isCopyable!T){}
static foreach (T; Types) static if (isAssignable!T){}
}
enum isSumType(T) = is(Args);
struct B {
SumType!(This)elems;
}
--
More information about the Digitalmars-d-bugs
mailing list