Uninitialized object hangs without warning.
    Bear Cherian via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Tue Nov 25 21:24:47 PST 2014
    
    
  
I ran into this a while ago and have already moved on, but I had 
a class such as this
Class MyClass{
     this(){}
     void someFunction(){
         //body
     }
}
And in my app I had something like
     MyClass classObject;
     classObject.someFunction();
When I compile, no warnings or errors. But when I run the 
application it just hangs at the function call. Eventually the 
app kills itself.
The problem is classObject is never initialized. This drove me 
crazy for an entire evening before I added a bunch of debug lines 
to narrow it down and then visually saw what the problem was.
I feel there should be some type of warning or error when 
compiling, or an error when we get to classObject.someFunction().
This is on 2.065, so forgive me if this has already been 
addressed. Again, it's been a while since I actually encountered 
the error, so not sure if i missed an aspect of it.
    
    
More information about the Digitalmars-d-learn
mailing list