title: Access Violation with no apparent nullptr
body: <p>I am writing an MFC application and have created a derived class <code>CStatusBarPane</code> which publicly derives from <code>CMFCRibbonStatusPane</code>. This derived class contains a simple method as follows:</p>
  
  <pre><code>virtual void SetStatusIcon( _In_ HICON hIcon )
  {
       m_hIconSmall = hIcon;
       Redraw();
  }
  </code></pre>
  
  <p>After the Main Frame is created (along with the status bar and its children panes), I call the following function:</p>
  
  <pre><code>void CMainFrame::UpdateStatusBar( _In_ const std::tstring&amp; szStatus, _In_opt_ HICON hIcon )
  {
       CStatusBarPane* pStatusBarPane = static_cast&lt;CStatusBarPane*&gt;(m_wndStatusBar.GetElement(0));
  
       pStatusBarPane-&gt;SetText( szStatus.c_str() );
       pStatusBarPane-&gt;SetStatusIcon( hIcon );
  }
  </code></pre>
  
  <p>However, when I debug the application, it raises an exception on the line <code>pStatusBarPane-&gt;SetStatusIcon( hIcon )</code> with the following statement:</p>
  
  <blockquote>
    <p>First-chance exception at 0x00000000 in Project.exe: 0xC0000005: Access violation executing location 0x00000000.</p>
  </blockquote>
  
  <p>However, looking at the variable trace shows that there are no null pointers being accessed, so I don't understand how I can have an access violation at address 0?</p>
  
  <p>Thanks in advance!</p>