About dynamic memery,allocate with new, free with delete[]

i know if use new[] to allocate a block of a specified type, and must use delete[] to free them,in this case, if use delete will result in memory leak.

but, what will happens, if use new to allocate memory and then use delete[] to free it?
Anyting. It is undefined behavior.
It might depend on how does enviroment stores array size info inside. It might do nothing, it might crash your program, it might free some unrelated memory and lead to problem in another part of your program...
thank you, it helped.
Topic archived. No new replies allowed.