Why is this memory referencing segfault? : <pre><code>double fun(int i)
{
 volatile double d[1] = {3.14};
 volatile long int a[2];
 a[i] = 1073741824;
 return d[0];
}
</code></pre>

<p>fun(0) ➙ 3.14</p>

<p>fun(1) ➙ 3.14</p>

<p>fun(2) ➙ 3.1399998664856</p>

<p>fun(3) ➙ 2.00000061035156</p>

<p>fun(4) ➙ 3.14, then segmentation fault</p>

<p>can someone explain to me whats going on in this example and why segfault dont show up when calling func(2)?
and why return value not always 3.14?</p>
