dmd 1.070 and 2.055 release
Max Samukha
maxter at spambox.com
Mon Sep 12 00:38:40 PDT 2011
On 09/11/2011 08:57 PM, 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!
That's sad. The question should rather have been: what do I do to use
member structs that have default constructors disabled? Initially I
thought that the compiler would treat the first assignment in the
constructor specially as initializer. The error message "Error:
constructor test.C.this field s must be initialized in constructor"
suggested that. I was wrong.
So you completely disallowed runtime initialization of globals and
members that have default constructors disabled? To me it looks like
another feature that is a simple solution unusable in practice.
More information about the Digitalmars-d-announce
mailing list