title: Segmentation fault in element_t array
body: <p>I use the <a href="https://crypto.stanford.edu/pbc/" rel="nofollow">PBC</a> library for a project, and I try to have a <code>element_t</code> array, where to store some data.</p>
  
  <p>I get a <code>segmentation fault</code> error when debugging with <code>gdb</code> when I try to copy an <code>element_t</code> into the array.</p>
  
  <p>Here is a MWE : </p>
  
  <pre><code>using namespace std;
  #include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  
  #include &lt;pbc.h&gt;
  #include &lt;pbc_test.h&gt;
  
  int main(int argc, char **argv) {
  
      const int t = 2;
      const int n = 3;
      element_t r[t];
      element_t s[n];
      pairing_t pairing;
      element_t P, s0, P0;
  
      pbc_demo_pairing_init(pairing, argc, argv); 
  
      cout&lt;&lt;"SETUP STAGE"&lt;&lt;endl;
  
      element_init_G1(P, pairing);
      element_random(P);
      element_printf("P = \t%B\n", P);
  
      /* Build the table with each element is r_i */
      element_t r_i;
      for (int i = 0; i &lt; t; i++)
      {   
          element_init_Zr(r_i, pairing);
          element_random(r_i);
          /* Put r_i into the array */
          element_set(r[i], r_i); // &lt;--- segmentation fault here
          element_clear(r_i);
  
      }
      /* Set s = r0 */
      element_init_Zr(s0, pairing);
      element_random(s0);
      /* Put it in the first place in the vector of all si */
      element_set(s[0], r[0]);
  
      /* Compute P = s*P0 */
      element_mul_zn(P0, P, s0);
      element_printf("P0 = %B\n", P0);
  
      element_clear(P);
  
      pairing_clear(pairing);
  
      return 0;
  }
  </code></pre>
  
  <p>I got this as error : </p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  0x000000000002721f in ?? ()
  </code></pre>
  
  <p>As anyone already tried putting <code>element_t</code>s in arrays ?</p>