title: In which case it is not safe to cast an object of base class to EMPTY derived class
body: <p>I use the following code to access a protected member of an object.</p>
  
  <pre><code>class Base {
  protected:
      void foo();
  };
  
  class PublicBase : public Base {
  public:
      static void bar(Base *obj) {
          static_assert(sizeof(PublicBase) == sizeof(Base), "Not today");
          static_cast&lt;PublicBase *&gt;(obj)-&gt;foo();
      }
  };
  </code></pre>
  
  <p>Can I assume that provided code is safe to use (in theory and in practice)?</p>