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

Why should it be a compile error? The pointer may be null, but is not guaranteed to be.

If you mean that C++ should require a null check before dereferencing any pointer that is not guaranteed to be non-null, then that would break most existing C++ code out there, so it's a non-starter.



in the particular situation they're talking about, you have a pointer to a struct, which you dereference by accessing one of its fields. the null check happens after the dereference, almost certainly a mistake.




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

Search: