title: Segmentation fault 11 while loop, but it seems there is no index out of bound
body: <p>I'm having trouble understanding why my c++ code causes a:</p>
  <blockquote>
  <p>segmentation fault: 11</p>
  </blockquote>
  <p>I have found at which line the error occurs but I still have no idea what is the problem.</p>
  <pre><code>double time_MC_loop[]={0.0, 0.0};
  while(order_loop&lt;=order-1 and T()&lt;time_MC)
    {
        order_loop+=1;
        if (order_loop!=order)
        {
            time_MC_loop[1]+=time_MC*pow(3.0,(double)order_loop-order-1);
            time_MC_loop[0]=time_MC*pow(3.0,(double)order_loop-order-1);
        }
        else
        {
            time_MC_loop[0]=-time_MC_loop[1]+time_MC;
            time_MC_loop[1]=time_MC;
        }
        
       //here I'm skipping parts of the code where I don't use either T() or time_MC_loop
        
        bool still_time=T()&lt;time_MC_loop[1];
        cout&lt;&lt;still_time;
        
        //when I write &quot;exit(1);&quot; here, I don't get a segmentation fault, 
        //and the program prints the expected value of the boolean still_time
        
        while(still_time)
        {
           exit(1);
           // However, I get a segmentation fault here, so it seems the bug occurs in the while test.
         //...
         }
  </code></pre>
  <p>Here <code>T()</code> is a timer that is defined in a library written by one of my colleagues. It returns a double that represents how long the program have been running for since the command <code>T.ini()</code> and until the command <code>T.fin()</code>. I have used it several times and it have never caused me such an issue, so I don't think it causes the problem.</p>
  <p>Thank you for your time!</p>