Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
devit
· 8y ago · 0 comments
Setting NULL or nullptr to any value other than 0 is highly likely to break most complex C/C++ codebases.
Comments
[–]
cyphar
8y ago
Even simple codebases that do
if (!p)
Anywhere would immediately cause problems.
[–]
saagarjha
8y ago
This is legal in C, even if the representation for a null pointer is not actually "all zero bits" internally. The null pointer is defined to compare equal to 0, which is the contrapositive of what your test is doing.