If we allocate an object of size 1 as below
int *arr = new int[1];
Should we delete the object using operator delete[]
or operator delete
?
The reason I am concerned is if the compiler would be smart enough to convert the statement as a single element allocation int *arr = new int
which would cause calling operator delete[]
UB.
User Case:
I have a pointer, which I would end up allocation in a varied ways but would finally like to get it deleted. So was wondering, for single element allocation, if I consistently use int *arr = new int[1]
can I consistently and safely use operator delete[]
Note
Can you please refer me back to the standards to support your answer?