>Fyi, the <= operator is explained at 11.8.5. It's all clearly documented.
That doesn't make it less bogus.
Reitter: Answering the question: "How do I develop an app for GNOME?"
Posted Feb 6, 2013 21:11 UTC (Wed) by renox (subscriber, #23785)
Yes, well known as it has created quite a few security vulnerabilities!
Posted Feb 6, 2013 22:00 UTC (Wed) by k8to (subscriber, #15413)
It's sort of a crazy language to the programmer but the cause is not premature optimization, but rather an attempt to be a very thin layer of helpful syntax over the system's native behavior. Since systems behave differently, you don't know what will happen, so it's undefined.
You can argue this was a bad design goal, but that's a different kind of error.
Posted Feb 7, 2013 6:00 UTC (Thu) by khim (subscriber, #9252)
Since systems behave differently, you don't know what will happen, so it's undefined.
If systems behave differently then it begs for “implementation-defined behavior”, not for “undefined behavior”. Much simpler and safer to deal with these. Indeed, the fact that C has so many “undefined behaviors” is a premature optimization - but the fact that someone made such error many years before is not an excuse to propagate this madness in newer, more modern languages.
Posted Feb 7, 2013 9:24 UTC (Thu) by ncm (subscriber, #165)
Posted Feb 7, 2013 11:46 UTC (Thu) by khim (subscriber, #9252)
You assume people write program to the spec. Well, newsflash to you: they don't. The very fact that both GCC and LLVM are trying (and failing) to catch a lot of undefined behaviors shows that people don't write to the spec. People write code, they write tests, if they pass - they are happy. That's it.
If program triggers implementation-defined behavior then tests are usually enough to catch problems (because compiler may do different thing from what the programmer expects but it consistently does different thing) while with undefined behavior compiler is absolutely free to do one thing in one case and completely different thing in another case. Which means that program may suddenly crash after compiler upgrade - and you have no idea why.
Copyright © 2018, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds