Code to reproduce:
---
struct S1 {
ubyte a;
ubyte[64] u;
}
struct S2 {
ubyte a;
ubyte[64] u;
}
void main(){
import std.variant, std.stdio;
Variant var1 = Variant(S1(1));
Variant var2 = Variant(const S1(2));
writefln("%s", var1 == var2);
}
---
Problem is in these lines https://github.com/dlang/phobos/blob/22055634e4b455135cebb65a2d562f21472c1e88/std/variant.d#L416-L418
Address to temp.store is passed to tryPutting, which expects address to memory of A.sizeof. So, tryPutting writes A.sizeof bytes into &temp.store corrupting the stack.
Comment #1 by robert.schadek — 2024-12-01T16:36:39Z