I was just reading about the bad practice of casting the return value of malloc
. If I understood correctly, it is absolutely legal to leave the cast as it is do
What you're looking at is implicit type conversion. This is considered safe if you're starting with a type having a more restricted range than the one you're ending up with, i.e. short to int is OK, as is float to double.
I'm quite surprised that gcc isn't generating a warning when converting a double to a float; I believe Microsoft's compiler does.