3 ms·
Easier said than done. There are better tools for finding undefined behaviour these days but they are pretty recent and far from perfect. For a taste of how co
by anon1385 13y ago
Easier said than done. There are better tools for finding undefined behaviour these days but they are pretty recent and far from perfect.
For a taste of how common undefined behaviour is, even in important code bases, (and why everybody should be using tools to test for it) see this post: http://blog.regehr.org/archives/1054 http://blog.regehr.org/archives/1054 "Integer Undefined Behaviors in Open Source Crypto Libraries"
Also the follow up about how difficult C sometimes makes it to avoid undefined behaviour without a performance penalty: http://blog.regehr.org/archives/1063 http://blog.regehr.org/archives/1063 "Safe, Efficient, and Portable Rotate in C/C++"
- joosters 13y agogcc 4.9 has a new UndefinedBehaviorSanitizer, -fsanitize=undefined - http://gcc.gnu.org/gcc-4.9/changes.html http://gcc.gnu.org/gcc-4.9/changes.html Perhaps this will help find these coding mistakes? (unfortunately, it seems to be a runtime checker and not a compile-time warning)
- DanWaterworth 13y agoAs others have pointed out, statically determining whether a program will invoke undefined behaviour is undecidable.
- joosters 13y agoAh, but it doesn't have to be exact to be useful. Spotting common cases and minimising false positives would be great, even if there was no guarantee of catching everything.
- Groxx 13y agoThat's like saying the halting problem is undecidable. Just because we can't make a general-case solution doesn't mean there isn't progress to be made.