title: Why does this code cause a Floating point exception - SIGFPE
body: <p>Using gcc 4.7:</p>
  
  <pre><code>$ gcc --version
  gcc (GCC) 4.7.0 20120505 (prerelease)
  </code></pre>
  
  <p>Code listing (test.c):</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  
  struct test {
      int before;
  
      char start[0];
      unsigned int v1;
      unsigned int v2;
      unsigned int v3;
      char end[0];
  
      int after;
  };
  
  int main(int argc, char **argv)
  {
    int x, y;
  
    x = ((uintptr_t)(&amp;((struct test*)0)-&gt;end)) - ((uintptr_t)(&amp;((struct test*)0)-&gt;start));
    y = ((&amp;((struct test*)0)-&gt;end)) - ((&amp;((struct test*)0)-&gt;start));
  
    return x + y;
  }
  </code></pre>
  
  <p>Compile &amp; execute</p>
  
  <pre><code>$ gcc -Wall -o test test.c &amp;&amp; ./test
  Floating point exception
  </code></pre>
  
  <p>The SIGFPE is caused by the second assignment (y = ...).  In the assembly listing, there is a division on this line?  Note that the only difference between x= and y= is casting to (uintptr_t).</p>