dmd 1.070 and 2.055 release
Ali Çehreli
acehreli at yahoo.com
Sun Sep 11 11:57:03 PDT 2011
On Sun, 11 Sep 2011 10:57:12 -0700, Walter Bright wrote:
> On 9/11/2011 9:08 AM, Max Samukha wrote:
>> This test case
>>
>> struct S
>> {
>> @disable this();
>> this(int x)
>> {
>> }
>> }
>>
>> class C
>> {
>> S s;
>> this()
>> {
>> s = S(42);
>> }
>> }
>>
>> void main()
>> {
>> auto c = new C;
>> }
>>
>> yields Error: default construction is disabled for type C
>>
>> Is it a bug?
>
> No, it's a feature!
class C
{
S s = S(0); // <-- initial value provided
this()
{
s = S(42);
}
}
Since C doesn't use any default constructed S, I would expect at least
the above to compile.
Could you please explain why the disabled default constructor of S
affects C in that case (and even in Max's case).
Thank you,
Ali
More information about the Digitalmars-d-announce
mailing list