3 ms·
According to http://stackoverflow.com/questions/6793262/why-dereferencing-a-null-pointer-is-undefined-behaviour http://stackoverflow.com/questions/6793262/why-d
by wolfgke 12y ago
According to http://stackoverflow.com/questions/6793262/why-dereferencing-a-null-pointer-is-undefined-behaviour http://stackoverflow.com/questions/6793262/why-dereferencing... dereferencing a null pointer is undefined behaviour. Thus the example in the unit test where this occurs is IMHO a serious bug.
- tokenrove 12y agoNote that in this case, what's actually happening is a null reference is being created; while this is very ugly (C++ references should never be null), if the reference isn't used, as the author asserts, a null dereference never happens (otherwise, there would almost inevitably be a crash). Behind the scenes it's just a NULL pointer being passed to the function that apparently ignores it.
- sharth 12y agoBut either way, the code is not well-formed. A null reference should never exist in a well-formed program. http://stackoverflow.com/questions/4364536/c-null-reference http://stackoverflow.com/questions/4364536/c-null-reference