title: What is causing my code to be non-deterministic?
body: <p>I might've gone crazy here, but I keep recompiling the <strong>exact</strong> same code, and get different answers. I'm not using any random values at all.  I am strictly staying to floats and 1D arrays (I want to port this to CUDA eventually).</p>
  
  <p>Is it possible on the compiler side that my same code is being redone in a way that makes it not work at all? </p>
  
  <p>I run the .exe by just clicking on it and it runs fine, but when I click "compile and run" (Dev C++ 4.9.9.2) none of my images come out right. ...although sometimes they do. </p>
  
  <p>...any insight on how I fix this? If I can provide any more help please tell me. </p>
  
  <p>Much Appreciated.</p>
  
  <p><strong>Edit:</strong> 
  Here's the block of code that if I comment it out, everything runs sort of right. (Its completely deterministic if I comment this block out) 
  -this is a electromagnetic simulator, if that helps at all:</p>
  
  <pre><code>        //***********************************************************************
      //     Update HZ in PML regions (hzx,hzy)
      //***********************************************************************
  
      boundaryIndex = 0;
      for (regionIndex = 1; regionIndex &lt; NUMBEROFREGIONS; regionIndex++) {
          xStart = regionData[regionIndex].xStart;
          xStop  = regionData[regionIndex].xStop ;
          yStart = regionData[regionIndex].yStart;
          yStop  = regionData[regionIndex].yStop ;
          for (i = xStart; i &lt; xStop; i++) {
              for (j = yStart; j &lt; yStop; j++) {
                  hzx = hz[i*xSize+j] - hzy[boundaryIndex];   // extract hzx
                  hzx = dahz[i*xSize+j] * hzx + dbhz[i*xSize+j] * ( ey[i*(xSize+1)+j] - ey[(i+1)*(xSize+1)+j] );    // dahz,dbhz holds dahzx,dbhzx
                  hzy[boundaryIndex] = dahzy[boundaryIndex] * hzy[boundaryIndex] + dbhzy[boundaryIndex] * ( ex[i*ySize+j+1] - ex[i*ySize+j] );
                  hz[i*xSize+j] = hzx +  hzy[boundaryIndex];  // update hz
                  boundaryIndex++;
              }  //jForLoop /
          }  //iForLoop /
      }  //
  </code></pre>
  
  <p>where, NUMBEROFREGIONS is constant (8), Xsize is defined at compile time (128 here).</p>