I have always been curious about this - why do in C++ I have to cast return value from malloc but not in C?

Here is the example in C++ that works:

int *int_ptr = (int *)malloc(sizeof(int*));

And here is the example in C++ that doesn't work (no cast):

int *int_ptr = malloc(sizeof(int*));

I heard that in C, in fact, casting an output from malloc() is a mistake.

Can anyone comment on this topic?

Edit
Report