Why does this simple program segfault?
Bill Baxter
dnewsgroup at billbaxter.com
Tue Aug 14 17:47:37 PDT 2007
Robert Fraser wrote:
> Bill Baxter Wrote:
>
>> Isn't there something we can do about this? I do this about once a day
>> when in a heavy D using phase. It bites newbies and not-so-newbies
>> alike. I almost think it should be made so that no initializer calls
>> the default constructor, and if you really want it to be null then you
>> should initialize with null:
>>
>> Tester fun; // creates a new Tester
>> Tester nofun = null; // doesn't create anything
>
> But then I (coming from a Java background) would be bitten by it about once a day.
>
> I think the best way is to make a compiler warning for every local variable that's used before it's explicitly assigned, a la Java (actually, it's an error in Java).
Assuming it applied only to classes in D, that seems like a good idea.
--bb
More information about the Digitalmars-d-learn
mailing list