Does a union always have default value of zero?
<p>Please let us consider following code:</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

union{
 int i;
}u;

int main(){

     int k=5;
     cout&lt;&lt;k+u.i&lt;&lt;endl;

    system("PAUSE");
    return EXIT_SUCCESS;
}
</code></pre>

<p>This code  shows me output  5,what means to me is that,variable i in union structure  has default value=0, but  the same code   on ideone.com  shows warning like this</p>

<pre><code>prog.cpp:6: warning: non-local variable ‘&lt;anonymous union&gt; u’ uses anonymous type and then prints  5 as well, and last one  core of this problem comes  from algorithm calculate  
</code></pre>

<p>Reciprocal of the square root  and here is code</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;math.h&gt;
using namespace std;

float invsqrt(float x){

    float xhalf=0.5f*x;

    union{
         float x;
         int i;
    }u;

   u.x=x;
   u.i=0x5f3759df-(u.i&gt;&gt;1);
   x=u.x*(1.5f-xhalf*u.x*u.x);

   return x;
}

int main(){

    float  x=234;
    cout&lt;&lt;invsqrt(x)&lt;&lt;endl;

    return 0;
}
</code></pre>

<p>It shows me output also,but my question  is that is it a this code good?i meant that because  int i is not initailized ,can any compiler consider it's value as zero?i  am curious  and please tell me something about this,also if something is not clear from my question  say me,i am not English native speaker.</p>
