Why I don’t get any error (C-style casting)

char c{ 10 };
int* i = (int*)&c;
*i = 1; // Run-Time Check Failure #2 - Stack around the variable 'c' was corrupted.

But I don’t get any error in this case

char* c = new char{ 10 };
int* i = (int*)&c;
*i = 1;
//delete c;

Why is it so?

Source: Windows Questions C++

LEAVE A COMMENT