3 ms·
>It should also be remembered that C++ compilers are even worse than C compilers at mis-using instances of undefined behavior to mis-optimize code, especially s
by fluoridation 4y ago
>It should also be remembered that C++ compilers are even worse than C compilers at mis-using instances of undefined behavior to mis-optimize code, especially since they typically rely even more on optimization steps to have half-decent performance.
Nonsense. Modern toolchains treat C and C++ as almost interchangeable. For example, Clang compiles both naively to a machine-independent IR and then performs all its optimizations on that. "C is portable Assembly" has been a myth for a long, long time. Nowadays C is effectively as high level as C++, just with fewer features.
- tsimionescu 4y agoThe Linux kernel uses GCC (for a long time, it used a specific version of GCC), and it uses some flags to disable certain notions of UB, some of which were particularly added for Linux. Do these work for C++ code? Possibly, but who knows.
- fluoridation 4y agoSo they had the GCC people define the behavior based on a flag. Since undefined behavior means that all behaviors are permissible, including defined behavior, I see no reason why any C++ compiler couldn't do this.