Y
Hacker News
new
|
ask
|
show
|
jobs
by
lurker19
5509 days ago
When is assigning a pointer to be boolean false intentional and correct?
3 comments
chandlerc
5509 days ago
Most of the cases we ran into were metaprogramming techniques which test whether an expression is a valid null pointer constants. These got innocently applied to 'false' and trigger the warning needlessly.
link
koenigdavidmj
5508 days ago
Done that before...had a variable that was formerly an int:
int foo = 0;
But got changed into a non-integral type:
Thing foo = 0;
Turns out Thing had a copy constructor roughly like:
Thing::Thing(Thing* old) : field(old->field) { }
Needless to say, my program was not very happy.
link
cpeterso
5509 days ago
I think the -Wconversion-null warnings are the other way around:
int i = NULL;
Because of C++'s conflation of NULL and 0 (and now C++0x's
nullptr
).
link