www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21613] New: DMD crash: copy ctor + templated rvalue ctor

https://issues.dlang.org/show_bug.cgi?id=21613

          Issue ID: 21613
           Summary: DMD crash: copy ctor + templated rvalue ctor
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: submada gmail.com

compiler version: DMD v2.095.0

1. This code print error (that is OK):

struct Test{   /////Error: struct Test may not define both a rvalue constructor
and a copy constructor

    this(ref const typeof(this) rhs){
    }

    this(const typeof(this) rhs){   
    }
}

void main(){
    const Test cb;
    Test b = cb;
}


2. This code crash DMD:

struct Test{  

    this(ref const typeof(this) rhs){
    }

    this()(const typeof(this) rhs){   ///<-- rvalue ctor is template
    }
}

void main(){
    const Test cb;
    Test b = cb;
}

--
Feb 05 2021