title: Why std::shared_ptr control block need to hold a pointer to managed object with its correct type
body: <p>I am looking at the shared_ptr implementation in the following <a href="https://stackoverflow.com/a/9201435/4208109">post</a>. One question that is not entirely clear to me is, why in addition to the pointer stored with <code>T*</code> type in shared_ptr class itself, author also needs to store the second copy of the managed object's pointer with its concrete type in the control block (i.e. <code>U* p;</code> in <code>auximpl</code>). I understand why we need this for custom deleter, but not for actual pointer. It looks like this complies with the requirements of the standard, when I read control block description in <a href="https://en.cppreference.com/w/cpp/memory/shared_ptr" rel="nofollow noreferrer">cppreference</a> page. Author made the following comment about this</p>
  <blockquote>
  <p>&quot;this is needed to properly manage all the cases of T being a base for
  whatever U having multiple T in the derivation hierarchy&quot;</p>
  </blockquote>
  <p>but I still can't come up with an example of when this will really be required. Can someone please demonstrate it with an example?</p>
  <p>Thank you,
  -Grigor</p>