2 ms·
Control over the code that actually runs. We already lose quite a bit of control with C (e.g. it reorders your code as it pleases) to gain portability across C
by 10x-dev 5y ago
Control over the code that actually runs.
We already lose quite a bit of control with C (e.g. it reorders your code as it pleases) to gain portability across CPUs, otherwise we'd have to rewrite the code in several assembly languages.
If you consciously choose to give up even more control over the code that runs (because a compiler that targets C necessarily adds another layer of autogenerated code that you don't control) then it better be a wise tradeoff.
- WithinReason 5y agoThe downside of reordering being performance? Or something else?
- 10x-dev 5y agoPerformance is usually the upside. The downside is subtle bugs that can happen due to side effects of the statements being reordered between sequence points.
- WithinReason 5y agoAFAIK compilers don't reorder if it would change the result.
- Thiez 5y agoCompilers not allowed to violate the language spec when optimizing. But the spec may be fairly generous in its allowed interpretations, which may not match what a programmer may naively expect. C, with its many undefined behaviors and implementation defined behaviors, is especially dangerous.