that's all over this project i inherited. happy monday: at least you don't have to write unit tests for this dreck.Code://lint -e{506} Suppress the "constant boolean" msg
if (NULL == &coefficients)
Printable View
that's all over this project i inherited. happy monday: at least you don't have to write unit tests for this dreck.Code://lint -e{506} Suppress the "constant boolean" msg
if (NULL == &coefficients)
let me preface this by saying that checking the address of an object or a reference is a sign of very bad design.
that being said, it is possible, under some circumstances, to have a reference that is essentially a dereferenced null pointer. in GTK+, for example, GUI event handler callbacks use a pointer to a function that receives a pointer to some data that you specify when you hook up the callback. if you are using GTK+ from a C++ program, you can tell it that a function that is declared as accepting a reference type parameter instead of a pointer should be used as the callback. since the function pointer is cast to a GCallback type when you hook it up, you can actually give it any function you want, and since most C++ implementations handle references behind the scenes as pointers, you can specify NULL for the data parameter, and when the callback gets called, the reference now refers to what amounts to a dereferenced null pointer. a former co-worker developed a lot of code this way, and it's likely the reason the program crashes so frequently. thankfully, that practice left with him, but its effects are still being felt.