4 ms·
The standard is clear about this: It's undefined behavior, and the compiler is allowed to make this assumption. The part that does the optimization might not ev
by detaro 6y ago
The standard is clear about this: It's undefined behavior, and the compiler is allowed to make this assumption. The part that does the optimization might not even be aware what the target platform is or does, and doesn't need to be. (And the discussion specifically about integer addition is probably decades-old, so it's unlikely you're going to change any compiler maintainers view on this now)
- jpegqs 6y agoOk, but isn't that the same as saying that if the manufacturer guarantees that the product you purchased will work for two years, then it may break immediately two years after purchase, and you cannot complain about that, because this behavior is completely legal.
- bobthebuilders 6y agoCopyright (C) 2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
- jpegqs 6y agoI know, but the point is to make the compiler more predictable, and therefore better. For example, CLANG doesn't have this issue. And this is related to a possible security vulnerability, so it should be taken more seriously.
- detaro 6y agoand clang could any day introduce this behavior if it happened as a consequence of a newly added optimization or something like this. Most "weird" cases like this are in the end consequences of optimizations (that people really want and expect of C) combining in a way that causes them. It's not like compiler authors add those issues for fun. C isn't friendly when it comes to this, UB is dangerous, but given the overall attitude of the ecosystem it's pretty pointless to complain about it.
- Gibbon1 6y agoYeah the only way this will ever be fixed if if the standard commit members get forced out and the standard fixed to stop this insanity.