title: Output spits two extra control characters, possibly a memory corruption bug?
body: <p>I have the following program test.cc:</p>
  
  <pre><code>#include &lt;iostream&gt;
  unsigned char bogus1[] = {
    // Changing # of periods (0x2e) changes output after periods.
    0x2e, 0x2e, 0x2e, 0x2e
  };
  unsigned int bogus2 = 1816; // Changing this value changes output.
  
  int main()
  {
    std::clog &lt;&lt; bogus1;
  }
  </code></pre>
  
  <p>I build it with:</p>
  
  <pre><code>g++ -g -c -o test.o test.cc; g++ -static-libgcc -o test test.o
  </code></pre>
  
  <p>Using g++ version 3.4.6</p>
  
  <p>I run it through valgrind and nothing is reported wrong.</p>
  
  <p>However the output has two extra control characters and looks like this:</p>
  
  <pre><code>....
  </code></pre>
  
  <p>That's a control-X and a control-G at the end.</p>
  
  <p>If you change the value of bogus2 you get different control characters.  If you change the number of periods in the array the issue goes away or changes.</p>
  
  <p>I suspect it is a memory corruption bug in the compiler or iostream package.</p>
  
  <p>What is going on here?</p>