Then you don't fully understand my point.I fully understand your point, but it just doesn't help to cast malloc().
If you pass the wrong type to sizeof then you've allocated the incorrect amount of memory. So cast or no cast your in trouble (haven't we been here before). This has nothing to do with the point I'm making. If you know you want space for 20 int's how could you possibly pass the wrong type to sizeof()?You can't see the decalaration of temp but you know it's type. So if you happen to pass the wrong type to sizeof(), then what's the point in casting the return of malloc()?]
My argument is nothing to do with looking at temps declaration. In fact my argument is based on the assumption that the coder has been sloppy and not looked at temps declaration. My argument is based on the coder knowing the amount of memory they need (as stated, casting is never going to help there), and what type of pointer they want to use to manoeuvre around this memory, but then selecting the wrong pointer.Yeah you could argue that you can just scroll up to temp's declaration, but then you'd never pass the wrong type to sizeof(), so what's your argument?
Look at my example and explain from what I've written there how casting wouldn't help. How casting wouldn't help prevent you making an incorrect assumption about the pointer type you're using? It currently has two bugs based on my false assumptions. If I had included casts these bugs would have been highlighted. So how does this mean casting doesn't help in any way?Casting doesn't help, in any way, IMO.