title: gcc creates crashing code depending on optimisation
body: <p>I have a rather complex multithreaded code, which I compile using gcc 4.8.1. When compiling with</p>
  
  <pre><code>g++ -c file.cc -march=native -mfpmath=sse -mpreferred-stack-boundary=4
  --param inline-unit-growth=50 -ggdb3 -Wall -Wextra -Winit-self
  -O2 -fPIC -funroll-loops -fforce-addr -rdynamic
  </code></pre>
  
  <p>the code produced crashes with segfault (which I was unable to debug, but the address of a struct all of a sudden differs from what it was when constructed, in particular, is no longer aligned to 32bytes as required by the code but only to 8bytes).</p>
  
  <p>When compiling with <code>-O1</code> instead, the code works fine. I then added all the optimisation flags that make the difference between <code>-O1</code> and <code>-O2</code>. (To this end, I created two files <code>O1-opts</code> and <code>O2-opts</code> via </p>
  
  <pre><code>g++ -march=native -mfpmath=sse -mpreferred-stack-boundary=4
  --param inline-unit-growth=50 -ggdb3 -Wall -Wextra -Winit-self
  -O1 -fPIC -funroll-loops -fforce-addr -rdynamic
  -Q --help=optimizers &gt; O1-opts
  
  g++ -march=native -mfpmath=sse -mpreferred-stack-boundary=4
  --param inline-unit-growth=50 -ggdb3 -Wall -Wextra -Winit-self
  -O2 -fPIC -funroll-loops -fforce-addr -rdynamic
  -Q --help=optimizers &gt; O2-opts
  </code></pre>
  
  <p>when <code>diff O1-opts O2-opts</code> provides the option differences). When adding <em>all</em> the option differences to <code>-O1</code>, the code generated still does not crash. This puzzles me. So my question is: shouldn't this give <em>exactly</em> the same result as with <code>-O2</code>? (and also: what is the likely cause of my problem?)</p>