I am looking at something that I discovered in an old code base, and I am pretty confused.
Here is a function definition:
void vUpdateSequenceDetailsAndIncrement(
const CallEvent& roCPEvent,
const CallInfo& roCallInfo,
BOOL bCreationEvent);
Here it is being called:
vUpdateSequenceDetailsAndIncrement(roCPEvent, NULL, FALSE);
Here NULL is being passed directly to the reference parameter roCallInfo
. This function eventually calls:
vTimeChange(*pSeqDetails, roCPEvent, roCallInfo);
which is defined:
void vTimeChange(const SequenceDetails& roSequenceDetails,
const CallEvent& roCPEvent,
const CallInfo& roCallInfo)
Again passing the possibly NULL value to roCallInfo
. I thought that NULL could not be passed as a reference? Does anyone know if VC++ 4.x had some kind of problem which made this kind of code okay? If NULL can be passed as a reference then what happens when in vTimeChange something like this happens:
roCallInfo.getCallStartTime();
Is that not a dereference of NULL in the same way as if I were to do
CallInfo * info = NULL;
info->getCallStartTime();
? I'll probably put a guard in there anyways and let the compiler remove it if unnecessary, but I'd love to get to the bottom of how this is happening!
Thanks.