Thread overview
[Issue 10186] default construction is disabled even if default ctor declared
Jan 07, 2015
Denis Shelomovskij
Dec 17, 2022
Iain Buclaw
Feb 27, 2023
RazvanN
January 07, 2015
https://issues.dlang.org/show_bug.cgi?id=10186

--- Comment #10 from Denis Shelomovskij <verylonglogin.reg@gmail.com> ---
Also one even can't create an array of class refereces:
---
struct S
{
    @disable this();
    this(int i) {}
}

class C
{
    S s;
    this() { s = S(1); }
}

void main()
{
    auto c = new C[1];  // line 15
}
---
main.d(15): Error: default construction is disabled for type main.C
---

Note:
This case is easily workaroundable e.g. setting `length` property.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=10186

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--
February 27, 2023
https://issues.dlang.org/show_bug.cgi?id=10186

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |FIXED

--- Comment #11 from RazvanN <razvan.nitu1305@gmail.com> ---
I cannot reproduce the first incarnations of this bug [1][2]. As for the 3rd provided test case [3], the sample is indeed invalid because the array of classes needs to enclose the the init value of the structs in the array elements, thus violating the @disable this() of struct S.

As such, this bug has been fixed.

[1] https://issues.dlang.org/show_bug.cgi?id=10186#c0
[2] https://issues.dlang.org/show_bug.cgi?id=10186#c3
[3] https://issues.dlang.org/show_bug.cgi?id=10186#c10

--