|
|
|
|
|
by madmax96
2390 days ago
|
|
How is strict aliasing magic? How could you possibly define the meaning of accessing an object through an incompatible type since the type of an object determines how the compiler interprets its value? The bits stored in the object do not even necessarily correspond to a value for every type, after all. And that's not even considering the fact that there is a great deal of freedom wrt how implementations can represent floating point numbers, etc. so how can the standard impose a requirement on what happens when you, say, access a double as an int? What do you mean by weak typing? That can you cast away basically anything? >It's easier to predict OCaml assembly output than the GCC's one Surely you are kidding. If that were true, why doesn't OCaml curb-stomp C in benchmarks? IMO GCC's output isn't even a little surprising, esp. once you've gained experience with its favorite optimizations. |
|
- 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