J
jason.cipriani
Is it OK to dereference NULL pointers if the only thing you are doing
is storing them in a reference then comparing addresses to NULL again
later, as in:
=== BEGIN EXAMPLE ===
Something g_something;
const Something & getSomething () {
if (condition)
return g_something;
else
return *(const Something *)NULL; // <--- !!!
}
void function () {
const Something &s = getSomething;
if (&s == NULL) { // <--- !!!
// ...
} else {
// ...
}
}
=== END EXAMPLE ===
Thanks,
Jason
is storing them in a reference then comparing addresses to NULL again
later, as in:
=== BEGIN EXAMPLE ===
Something g_something;
const Something & getSomething () {
if (condition)
return g_something;
else
return *(const Something *)NULL; // <--- !!!
}
void function () {
const Something &s = getSomething;
if (&s == NULL) { // <--- !!!
// ...
} else {
// ...
}
}
=== END EXAMPLE ===
Thanks,
Jason