title: C++ loop hangs if any code is added inside if Condition
body: <p>I have the following code with strange behaviour:</p>
  
  <pre><code>struct Mime {
      int key;
      string value;
  };
  
  class Storage {
  
  private:
  
      int Size;
      Mime * _storage;
      int last = 0;
  
  public:
  
      Storage(int __size) {
          Size = __size;
          _storage = new Mime[Size + 2];
      }
  
      void add(const Mime &amp; __mime) {
  
          for (int x = 0; x &lt; last; x++)
              if (_storage[x].key == __mime.key) {}
  
          _storage[last++] = __mime;
      }
  };
  
  void test2() {
  
      int thisSize = 1000000;
      Storage storage(thisSize);
      auto start_t = chrono::high_resolution_clock::now();
      for (int i = 0; i &lt; thisSize; i++) {
          Mime temp;
          temp.key = i;
          temp.value = "Hey";
          storage.add(temp);
      }
      cout &lt;&lt; chrono::duration_cast&lt;chrono::milliseconds&gt;(chrono::high_resolution_clock::now() - start_t).count() &lt;&lt; " milliseconds\n" &lt;&lt; endl;
  }
  
  
  int main() {
  
      test2();
  
      cout &lt;&lt; "Done" &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>This code run in 120 milliseconds for me. But when I add some code here inside the <code>{}</code></p>
  
  <pre><code>if (_storage[x].key == __mime.key) {}
  </code></pre>
  
  <p>like </p>
  
  <pre><code>if (_storage[x].key == __mime.key) { return; }
  </code></pre>
  
  <p>or anything else...
  Then my program runs in 10 mins or sometimes hangs by adding <code>return;</code> or any other code. When I add  <code>return;</code> or any other code in this <code>if</code> condition, my program hangs. In this (if) nothing happens in the process because this doesn't seem to run the <code>return;</code> or any other code. </p>
  
  <p>Any suggestions?</p>