Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Build this code with any reasonable warning setting (gcc's defaults are really minimal) and you will get a warning for this, since it's detectable at compile time. Other undefined behavior is harder to catch at compile time, but clang (and possibly other compilers) have tools to catch at runtime.


As is mentioned in the comments, in the author's original code that inspired the post, it was an uninitialized struct member. With pointer arithmetic and everything, I would have a really hard time detecting an uninitialized struct member at compile time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: