Dynamic allocation of an array of size 0

Possible duplicate:
C ++ new int [0] - will it allocate memory?

What should happen when I do this:

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

MakeArray( 0 );

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

PS: Please do not tell me to use the vector or check the size before highlighting, I know all this. this is not my code. I'm just curious.

+3
source share
1 answer

Very similar to this question . The answer is that it should work

+1

Source: https://habr.com/ru/post/1733494/


All Articles