Why does this simple program segfault?

Jascha Wetzel "[firstname]" at mainia.de
Tue Aug 14 16:53:36 PDT 2007


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 there's all sorts of questions that crop up, like what should 
> "new Tester[5]" do?  Or "Tester m_fun;" as a class/struct member.
> 
> I guess the best we can hope for is some kind of better error message 
> than just a generic segfault, or perhaps a compiler warning if you 
> forget to initialize a class instance.
> 
> --bb

it would be nice to have a way to specify the default initializer for 
any type.


More information about the Digitalmars-d-learn mailing list