title: segfault when setting bool possible?
body: <p>I have a binary tree, whose nodes are defined as</p>
  
  <pre><code>typedef unsigned long ul;
  struct Fibonacci_node{
      ul number;                              
      int n;                                 
      bool isLeaf;                            
      Fibonacci_node * left;
      Fibonacci_node * right;
    };
  </code></pre>
  
  <p>I'd like to set <code>isLeaf</code> each insertion, so that I could easily get the total number of leafs eventually. The insertion method is made up of a public method, <em>insert</em>, that calls the private recursive method <em>insertR</em>.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Fibonacci_tree{
      private:
          struct Fibonacci_node{
          ul number;                              // store the n-th fibonacci number
          int n;                                  // fibonacci number to compute
          bool isLeaf;                            // true if the node is leaf
          Fibonacci_node * left;
          Fibonacci_node * right;
        };
  
  
  
          /* definition of the root of the binary tree */
          Fibonacci_node * root;
  
          /* class private methods (recursively defined) */
          ul fibonacci(int n){
          /* BASE CASE */
          if (n == 0) { return 1; }
          if (n == 1) { return 1; }
  
          /* call the function recursively */
          return fibonacci(n - 1) + fibonacci(n - 2);
        };
  
        Fibonacci_node * insertR(int n, Fibonacci_node * node){
          if (!node) {
          /* if pointer is null create a new node */
  
          Fibonacci_node * tmp = new Fibonacci_node;
          tmp-&gt;n = n;
          tmp-&gt;number = fibonacci(tmp-&gt;n);
          tmp-&gt;left = tmp-&gt;right = 0;
          tmp-&gt;isLeaf = 0;
  
          /* update the pointer and return it */
          node = tmp;
  
          /* BASE CASE */
          if (n == 0) {
            node-&gt;isLeaf = 1;
            return node;
          }
          if (n == 1) {
            node-&gt;isLeaf = 1;
            return node;
          }
        }
  
        /* call the function recursively */
        node-&gt;left = insertR(n - 1, node-&gt;left);
        node-&gt;right = insertR(n - 2, node-&gt;right);
  
        return node;
      };
  
    public:
      Fibonacci_tree(){
        root = 0;
      }
      ~Fibonacci_tree(){}
  
      /* class public methods (they include private methods recursively defined)*/
      void insert(int n){
  
        /* first, create initial node and compute fibonacci for the root */
        Fibonacci_node * tmp = new Fibonacci_node;
        tmp-&gt;n = n;
        tmp-&gt;number = fibonacci(n);
        tmp-&gt;isLeaf = false;
        //getNo(tmp);
  
        /* make root point to the first element of the tree */
        root = tmp;
  
        /* then call the recursive function */
        root = insertR(n, root);
      };
  };
  /* END OF CLASS DECLARATION */
  
  
  /* main program to check the class */
  int main(void) {
    int n = 3;
  
    /* instantiate a Fibonacci tree */
    Fibonacci_tree fib_series;
    /* fill the tree */
    fib_series.insert(n);
  
    return 0;
  }
  </code></pre>
  
  <p>When I run my executable, I get</p>
  
  <pre><code>Segmentation fault: 11
  </code></pre>
  
  <p>I printed several comments and I noted that the error seems appear immediately after before I assign "false" to the boolean. So, I'm assuming that the assignment gets wrong but it's the first time I get segmentation fault in such a situation.</p>
  
  <p>I also think that because so far I haven't had any problem but this, and it started when I introduced this variable in the class definition.</p>
  
  <p>Could it be possible to get segmentation fault because of this, or I may have a problem elsewhere that I haven't noted yet?</p>
  
  <p>I'd like to completely debug it by myself, but my debugging skills still sucks a bit. Any feedback is therefore really appreciated.</p>