title: What is the reason for a segmentation fault with this C++ code using lists?
body: <p>I have some complicated C++ code but the problem narrows down to doing a <code>push_back</code> on a list of structures:</p>
  
  <pre><code>list&lt;cache_page&gt; cachedPages;
  
  void f()
  {
      cache_page cpage(a,b);
      cachedPages.push_back(cpage);
  }
  </code></pre>
  
  <p>I have commented all the data members of the <code>struct cache_page</code> and still the error persists. If I comment the <code>push_back</code> line, there is no error.</p>
  
  <p>What could be the reason?</p>
  
  <p>I have tried using <a href="http://en.wikipedia.org/wiki/GNU_Debugger" rel="nofollow noreferrer">GDB</a> and the error occurs in <code>_List_Node_base::hook()</code> function.</p>
  
  <pre><code>template &lt; class T &gt;
  class A
  {
      T x;
      public:
          void func()
          {
            x-&gt;f();
          }
  
  };
  
  class B : public A &lt; B* &gt;
  {
      list&lt;cache_page&gt; cachedPages;
      public:
          void f()
          {
              cache_page cpage;
              cachedPages.push_back(cpage);
          }
  };
  </code></pre>
  
  <p>I have a do nothing copy constructor. I have no data members in cache_page.</p>