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

I mean, "obviously" if you don't initialize your variables, they'll contain garbage. You can't assume that garbage is zero/false, or any other meaningful value.

But re the distinction at the end of TFA — that a garbage char is slightly more OK than a garbage bool — that's also intuitive. Eight bits of garbage is always going to be at least some valid char (physically speaking), whereas it's highly unlikely that eight bits of garbage will happen to form a valid bool (there being only two valid values for bool out of those 256 possible octets).

This also relates to the (old in GCC but super new in Clang, IIUC) compiler option -fstrict-bool.



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

Search: