3

Possible Duplicate:
C++ new int[0] — will it allocate memory?

What is supposed to happen when i do this:

int * MakeArray( std::size_t Size ) {
    return new int[ Size ];
}

MakeArray( 0 );

We had this is out code (using VC++ 2005), and the debug-heap complained about a memory-block of size 0 that was not deallocated. Is it standard to return an array of size 0 here?

P.S.: Please don't tell me to use vector or check for the size before allocation, I know all those. it's not my code. I'm just curious.

Community
  • 1
  • 1
Björn Pollex
  • 70,106
  • 28
  • 177
  • 265

0 Answers0