2 ms·
Many C programs are vailid C++ and are faster when compiled with a C++ compiler because of those stricter aliasing and type rules. Like you though I have no exa
by bluGill 10mo ago
Many C programs are vailid C++ and are faster when compiled with a C++ compiler because of those stricter aliasing and type rules. Like you though I have no examples.
- _qib3 10mo agoThat seems very odd - if it's possible to make those optimisations without any additional type data then why wouldn't GCC do that anyway? The benefit of stricter type rules is that more information is available to the compiler. Using a different compiler doesn't inherently increase the amount of type information.
- tcfhgj 10mo agotheoretically the C++ compiler needs to consider things like exceptions which don't exist in C, so I'd even tend to the opposite
- aw1621107 10mo agoI believe the claim is more precisely stated as "Many C programs are valid C++ and are faster when compiled as C++" - i.e., even though the text of the program didn't change, the rules for interpreting that text changed, and it's that difference in interpretation that permits better optimizations.
- teo_zero 10mo agoInteresting concept! Any examples?