I am in the beginning stages of writing a fairly large code. I have defined one class as such:
class GPUMD {
    private:
        double xhi, xlo, yhi, ylo, zhi, zlo;
        int numAtoms;
        Atom *atoms;
    public:
        GPUMD();
        ~GPUMD();
};
The destructor is defined as below:
GPUMD::~GPUMD() {
    if(atoms != NULL)
        delete [] atoms;
}
Right now, the code does this:
int main(int argc, char *argv[]) {
    GPUMD gpumd;
    exit(0);
}
I get a glibc detected error: trying to free invalid pointer. Using valgrind, I see that this error traces to my destructor for GPUMD. For some reason, the atoms != NULL test is returning true even though I have not assigned anything to that pointer. Why is that?
EDIT: The constructor is defined as:
GPUMD::GPUMD() {}
 
     
     
    