On Thursday, 10 April 2014 at 11:39:16 UTC, Andrej Mitrovic wrote:
On 4/9/14, Brian Schott <[email protected]> wrote:
Really? What does this program print using a current version of
DMD?

import std.stdio;

struct SomeStruct
{
        this(int i = 10)
        {
                this.i = i;
        }
        int i;
}

void main(string[] args)
{
        auto s = SomeStruct();
        writeln("s.i = ", s.i);
}

This is a current bug that is going to be fixed:
https://github.com/D-Programming-Language/dmd/pull/1397


Please do not forget about C++ porting problems that are related to this. The code from C++ should compile and work as expected or does not compile at all and give meaningful error message.
Right now it compiles but does not work at all.
This struct constructor problem is one of the ground why I have stopped porting code to D.
I hope there will be proper solution soon.


Reply via email to