Will we get SEGV if we try to “delete []” un-initialized integer pointer variable.

I have a class with an integer pointer, which I have not initialized to NULL in the constructor. For example:

class myclass
{
private:
char * name;
int *site;
}

myclass:: myclass(....)
: name(NULL)
{
.....
}

other member function �delete [] � the variable before initializing it.

Ex:
void myclass:: copy_site ( int **Values, int *from)
{
int *old;

old = *values.

Delete [] old; <<<<<� here I am getting SEGV
...............
..............
}

But I am getting SEGV at �delete []�.

Surprisingly it is not happening every time. For only some inputs it is certainly working fine.

What could be the reason?
If it is because of initialization, why is working for some inputs and certainly not for other inputs?

I have observed with workshop that, for some inputs it is automatically getting initialized to NULL, and for other inputs it is certainly not NULL (dangling pointer).

Thanks in advance,
Suresh

Though I am not sure of the exact reason but this could be a probable reason:

When we want to delete the contents of an array allocated with new[], we need to use the delete[] operator. Whether we have to use the delete or the delete[] operator - we need to tell this to compiler, cause for example an 'int*' could either point to a single integer, allocated using 'new int', or to an array of integers.

If we allocate an array of integers like int* var = new int[5];
then we should explicitly delete the array by calling delete [] var which would tell the compiler to free all the memory as held by the array.

Similarly there could be a problem if we allocate memory for a array element using new, and later try to de-allocate it using delete[]. We might get memory corruption - since compiler might try to delete whole memory for an entire array - while we have only allocated memory for a single element.

In main() I have two objects of different classes say class1 & class2.

Class1 and class2 both uses pointer variables. Class1 initializes all the pointer variables but class2 doesn't.

My observation is:

If I just instantiate class1 and class2 and then start using it no problem is occurring. (That is class2 pointer variables by default getting initialized to NULL).

But if I instantiate class1 and allocate some memory to its pointer member variables, immediately free it, and then instantiate class2, I am surely getting dangling pointer in class2 members.

Is it the right cause I have analyzed?