wxPropertyGrid is using NULL references
Brought to you by:
jmsalli
While looking for another problem I noticed wxPropertyGrid uses NULL references for wxPG_LABEL. According to the C++ spec. this is undefined behavior :
Note: in particular, a null reference cannot exist in a well-defined program, because the only way to create such a reference would be to bind it to the "object" obtained by
dereferencing a null pointer, which causes undefined behavior
(section 8.3.2 item 4)
So, although it currently works at least on the compiler I am using, it may do weird things on other compilers/platforms.
Yes, I know NULL references are bad C++, reduce code readability, and should be avoided in clean code. However, when used carefully (mostly as default values in case of wxPG - sometimes I dislike that there is no such thing as NULL reference in C++) there really isn't too much harm in them - after all references are quite close to pointers in their function, and NULL pointers are valid (assignment to a reference is a problem, so whoever is using them needs to know what they are doing ;). IIRC, as of this date there has not been a single bug in wxPG that would have been caused by NULL references.
Anyhow, I have already got rid of most if not all NULL references in wxPG in wxWidgets 2.9, and might just as well do that for the 1.4 branch at some point.
But either way, AFAIK nothing is really broken at this moment :) NULL references in wxPG go way back, and nobody has reported a compilation errors or warnings regarding them. Naturally I will fix such things.
Thanks,
Jaakko