title: How to remove unused methods of virtual classes in GCC?
body: <p>To eliminate dead code I use GCC's compiler options <code>-fdata-sections -ffunction-sections</code> and linker option <code>-Wl,--gc-sections</code>. It's work fine except the case of unused methods of <em>virtual</em> classes.</p>
  
  <p>For example,</p>
  
  <pre><code>class A {
  public:
      virtual void f();
  };
  
  class B: public A {
  public:
      void unused();
  };
  
  class C {
  public:
      void unused();
  };
  </code></pre>
  
  <p>GCC keep <code>B::unused()</code>, but remove <code>C::unused()</code>.</p>
  
  <p>How to force GCC remove unused methods of virtual classes?</p>
  
  <p><strong>UPD.</strong> I've googled <code>-fvtable-gc</code> option, but it doesn't work.</p>