title: Segfault when accessing next node in singly linked list
body: <p>I'm trying to just reverse a singly linked list, but with a bit of a twist. Rather than having the pointer to the next node be the actual next node, it points to the pointer in that next node. </p>
  
  <pre><code>struct _Node
  {
      union
      {
          int n;
          char c;
      } val;
      void *ptr; /* points to ptr variable in next node, not beginning */
      int var;
  };
  typedef struct _Node Node;
  </code></pre>
  
  <p>I know how to reverse a normal singly linked list and I think I have the general idea of how to go about solving this one, but I'm getting a segfault when I'm trying to access <code>head-&gt;ptr</code>and I don't know why.</p>
  
  <pre><code>Node *reverse(Node *head)
  {
      Node * temp;
      Node * prev = NULL;
      while(head != NULL)
      {
          temp = head-&gt;ptr + 4; /* add 4 to pass union and get beginning of next node */
          head-&gt;ptr = prev;
          prev = head;
          head = temp;
      }
      return prev;
  }
  </code></pre>
  
  <p>Even if I try and access <code>head-&gt;ptr</code> without adding 4, I get a segfault.</p>
  
  <p>The driver that I have for this code is only an object file, so I can't see how things are being called or anything of the sort. I'm either missing something blatantly obvious or there is an issue in the driver. </p>