title: NULL passed directly to a function expecting a const reference parameter (VC++ 4.2)
body: <p>I am looking at something that I discovered in an old code base, and I am pretty confused.</p>
  
  <p>Here is a function definition:</p>
  
  <pre><code>void vUpdateSequenceDetailsAndIncrement(
              const CallEvent&amp; roCPEvent,
              const CallInfo&amp; roCallInfo,
              BOOL bCreationEvent);
  </code></pre>
  
  <p>Here it is being called:</p>
  
  <pre><code>vUpdateSequenceDetailsAndIncrement(roCPEvent, NULL, FALSE);
  </code></pre>
  
  <p>Here <strong>NULL</strong> is being passed directly to the reference parameter <code>roCallInfo</code>. This function eventually calls:</p>
  
  <pre><code>vTimeChange(*pSeqDetails, roCPEvent, roCallInfo);
  </code></pre>
  
  <p>which is defined:</p>
  
  <pre><code>void vTimeChange(const SequenceDetails&amp; roSequenceDetails,
          const CallEvent&amp; roCPEvent,
          const CallInfo&amp; roCallInfo)
  </code></pre>
  
  <p>Again passing the possibly NULL value to <code>roCallInfo</code>. 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:</p>
  
  <pre><code>roCallInfo.getCallStartTime(); 
  </code></pre>
  
  <p>Is that not a dereference of NULL in the same way as if I were to do</p>
  
  <pre><code>CallInfo * info = NULL;
  info-&gt;getCallStartTime();
  </code></pre>
  
  <p>?
  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!</p>
  
  <p>Thanks.</p>