September 14, 2012
I have a struct, which defines a constructor that takes an argument.

Now, I'd like to new this object, to it's default T.init value (eg call new, but now constructors):

--------
struct S
{
    this(int);
}

void main()
{
    auto p1 = new S;
    auto p2 = new S();
}
--------
main.d(8): Error: constructor main.S.this (int) is not callable using argument types ()
main.d(8): Error: expected 1 function arguments, not 0
main.d(9): Error: constructor main.S.this (int) is not callable using argument types ()
main.d(9): Error: expected 1 function arguments, not 0
--------
Is this a bug? If "auto a = S();" is legal, how can "auto p = new S();" not be?
September 14, 2012
On Fri, 14 Sep 2012 14:27:56 -0400, monarch_dodra <monarchdodra@gmail.com> wrote:

> I have a struct, which defines a constructor that takes an argument.
>
> Now, I'd like to new this object, to it's default T.init value (eg call new, but now constructors):
>
> --------
> struct S
> {
>      this(int);
> }
>
> void main()
> {
>      auto p1 = new S;
>      auto p2 = new S();
> }
> --------
> main.d(8): Error: constructor main.S.this (int) is not callable using argument types ()
> main.d(8): Error: expected 1 function arguments, not 0
> main.d(9): Error: constructor main.S.this (int) is not callable using argument types ()
> main.d(9): Error: expected 1 function arguments, not 0
> --------
> Is this a bug? If "auto a = S();" is legal, how can "auto p = new S();" not be?

It is a bug.

http://d.puremagic.com/issues/show_bug.cgi?id=4247

-Steve