www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20793] New: Variant equals of different types


          Issue ID: 20793
           Summary: Variant equals of different types
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: mrsmith33 yandex.ru

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

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.

May 02 2020