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

In C you have no exception handling. The closest you can get is seqfualts. With a segfault the debugger can give you a backtrace at almost the exact issue point.

The easiest way to get segfaults is by dereferencing NULL. In C dereferencing NULL is invalid. Thus returning NULL on failure will result in something close to what raising an exception in other languages does.

In any language with real exception handling it makes much less sense, ignoring optimization.



Dereferencing NULL is undefined -- on AIX the page at 0x0 is readable.


You don't need to fault the program to take a stack trace.


setjmp and longjmp can be used for exception handling, if you want to lose your mind.




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

Search: