3 ms·
> Making C compilers for different architectures output great code from same source is really hard. e.g. "const" is not used by optimizers because it can be cas
by jmgao 10y ago
> Making C compilers for different architectures output great code from same source is really hard. e.g. "const" is not used by optimizers because it can be cast away.
const most certainly is used by optimizers: https://godbolt.org/g/kLmGr4 https://godbolt.org/g/kLmGr4
The willingness of C compilers to (ab)use undefined behavior for optimization is one of the main criticisms against it.
- flamedoge 10y agoI think the argument is not against unwillingness, but when and how.
- beached_whale 10y agoCheck out the cppcon 2016 presentation by Jason Turner and watch how eager the compiler optimizes away code when const is enabled on values. Cool presentation too, and uses Godbolt's tool https://www.youtube.com/watch?v=zBkNBP00wJE https://www.youtube.com/watch?v=zBkNBP00wJE