[Issue 22639] New: Copy constructors with default arguments not getting called

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 31 03:26:45 UTC 2021


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

          Issue ID: 22639
           Summary: Copy constructors with default arguments not getting
                    called
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: scienticman at gmail.com

```
import std.stdio:writeln;

struct A
{
    this(ref return scope A rhs) inout {}                        
    this(ref return scope const A rhs, int b = 7) inout {                       
        if (b != 7) {
            this.b = b;
        }               
    }

    this(this) @disable;

    int a=4;
    int b=3;
}

void main()
{
    A a = A();
    //A c = A(a,10); // Doesn't work :(
    /+
    A c = void;
    c.__ctor(a, 200); //works if I write like this
    +/
    A* b = new A(a, 10); //But this works!
    writeln(b.b);
    writeln(c.b);
}
```

--


More information about the Digitalmars-d-bugs mailing list