int main(void) {
const char* kung = "Foo";
delete []kung;
}
In this piece of code, why do I get the following debug assert failed block_type_is_valid ?
Is it because kung pointer is pointing to a constant string in the memory which cannot be de-allocated ?
Because you can’t
deletea string literal (which is whatkungpoints to).You also can’t delete an automatic-storage string (so it’s not really the literal part):
Only
delete[]memory you allocate withnew[].