2 ms·
> What is the “right” thing to do with UB It is actually quite clear in most of specific cases, as Linus pointed even 18 years ago: https://gcc.gnu.org/legacy
by acqq 7y ago
> What is the “right” thing to do with UB
It is actually quite clear in most of specific cases, as Linus pointed even 18 years ago:
https://gcc.gnu.org/legacy-ml/gcc/2002-01/msg00418.html https://gcc.gnu.org/legacy-ml/gcc/2002-01/msg00418.html
"When it comes to optimization, there are things that are "obvious", and
that will never generate any discussion at all, because they are faster
ways of getting the exact same result, with no question about it. Nobody
will ever fault a compiler for evaluating constant expressions at
compile-time rather than doing the math at run-time and getting the same
result. The two are indistinguishable from a result standpoint.
But optimizations that can change the value of an expression are slightly
different. They should make sense. You should be able to _explain_ them."
"If you cannot explain the results, you end up having to argue about
word-weaseling in the standard, and people _will_ disagree on what the
damn thing means. Because standards aren't mathematically exact things."