title: Phantom Bugs using Queue (STL Library), Windows/MingW/G++
body: <p>I'm having two unexpected problems using Queue from the STL Library:</p>
  
  <p>1) I'm trying to clear a Queue (Queue does not have a function clear),
  but the intuitive way is giving me a CORE DUMP:</p>
  
  <pre><code>//The queue is defined Globally but the problem happens even
  //if i define it locally and pass it by reference.
  queue&lt;pair&lt;int,int&gt; &gt; Q;
  
  void yadayada ()
  {
      //initialize Q
      while (!Q.empty())
          Q.pop();   //CORE DUMP, what the hell?
  }
  </code></pre>
  
  <p>2) When i print the element(a pair) from the queue front it is
  wrongly printed as (0,0). But when i use the element (returning
  the second element of the pair) it is right!</p>
  
  <pre><code>int yadayada2(...) 
  {
  //code...code...code
  
  //the element in front is (4,20)
  front = Q.front(); Q.pop();
  
  cout &lt;&lt; "(" &lt;&lt; front.first &lt;&lt; "," &lt;&lt; front.second &lt;&lt; ")" &lt;&lt; endl;
  //prints: (0,0) 
  //what the hell?
  
  //correctly returns 20
  return front.second;
  }
  
  int main()
  {
  //code...code...code 
  
  //prints 20!
  cout &lt;&lt; yadayada2 &lt;&lt; endl;
  }
  </code></pre>
  
  <p>I though: "Maybe the pop invalidates the element (does not make sense but...)
  so i moved the Q.pop(); to just before the return. But the same thing still happens...</p>