4 ms·
Not only can you cast away anything, but: - casting away types unsafely is required for many common patterns in C, including any form of runtime polymorphism
by wwright 7y ago
Not only can you cast away anything, but:
- casting away types unsafely is required for many common patterns in C, including any form of runtime polymorphism
- basically anything involving numerics has a good chance of happily casting for you without asking you or telling you
- madmax96 7y ago>- casting away types unsafely is required for many common patterns in C, including any form of runtime polymorphism Which patterns? I'm thinking of stuff like the Berkeley Sockets API, which you can absolutely implement safely. re numerics: fortunately, that's 100% amenable to static analysis (see -Wconversion, -Wsign-conversion in gcc/clang and coverity's warnings about potentially unsafe casts - e.g. promoting an int to a long is always safe, but an int to a float not necessarily) and follows very straightforward rules.