2 ms·
Even if we ignore the massive complexity problems with whole-program analysis, what if you can't globally prove how the pointer is used? Pointer arithmetic can
by AlisdairO 11y ago
Even if we ignore the massive complexity problems with whole-program analysis, what if you can't globally prove how the pointer is used? Pointer arithmetic can be done based on runtime information. A compiler doesn't have access to knowledge like 'this system will never encounter data that causes those pointers to alias'. If you add a system to provide information like that, well, you're pretty much defining a language extension right there.
Now, obviously you'd hope that people aim not to write programs that rely so subtly hopes and dreams of runtime information, but hopefully it's illustrative as a counterexample.
- cactusface 11y agoAlso consider that fixed point optimization algorithms can only ever approach the optimal solution. Languages that are closer to the hardware generally have simpler (tighter) optimization constraints, and compilers for them will generally get closer to the optimal solution.