Howdy,
I've just tried out std.variant
and I've noticed that I can induce a segfault by having a variant of variants. Should this work?
import std.stdio;
import std.variant;
void main()
{
Variant variant = Variant([
"one": Variant(1),
"two": Variant(2),
"three": Variant(3)
]);
writefln("Segfault occurs on the next line");
variant["four"] = Variant(4); // Segfault
writefln("This line will not be reached");
}
For whatever reason, the variant["four"] = Variant(4)
line will fail with a segfault. I'm using LDC2:
LDC - the LLVM D compiler (1.31.0):
based on DMD v2.101.2 and LLVM 14.0.3
built with LDC - the LLVM D compiler (1.31.0)
Default target: x86_64-unknown-linux-gnu
Host CPU: ivybridge