Hacker News new | past | comments | ask | show | jobs | submit login

Yes. In C, conversion between object pointer types requires a cast, but conversion from void pointer to object pointer does not; in C++, both conversions require a cast.

Conversion from void pointer to object pointer would be very a bit annoying to warn about in general, as it's so commonly used in C. And if you always use casts, that also hide other types of error (see, e.g., http://c-faq.com/malloc/mallocnocast.html).

I'm sure there are compilers (and possibly gcc/clang can do it, too...) that will warn you about this stuff without needing you to switch to C++.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: