title: Odd behavior with unsigned 16 bit integers and SDL_TTF
body: <p>I'm writing a program that renders font in SDL. I have a struct with the color and text of a 'pixel.' It causes a segmentation fault, and I can't make any sense of it.</p>
  
  <pre><code>struct pixInfo
  {
      SDL_Color bColor;
      SDL_Color tColor;
      Uint16 ch;
  };
  </code></pre>
  
  <p>And this is the rendering code</p>
  
  <pre><code>fchar = TTF_RenderGlyph_Solid(com-&gt;font, im-&gt;ch, im-&gt;tColor); // Segmentation fault
  </code></pre>
  
  <p>com is a pointer to the main class, which stores the font.
  im is an iterator to a pixInfo struct
  fchar is a SDL_Surface*
  This will crash if im->ch is something like 9554 (ASCI characters work fine)</p>
  
  <p>However, This code does work</p>
  
  <pre><code>fchar = TTF_RenderGlyph_Solid(com-&gt;font, 9554, im-&gt;tColor);
  // OR
  Uint16 num = 9554;
  fchar = TTF_RenderGlyph_Solid(com-&gt;font, num, im-&gt;tColor);
  </code></pre>
  
  <p>This does not work:</p>
  
  <pre><code>Uint16 num = im-&gt;ch;
  fchar = TTF_RenderGlyph_Solid(com-&gt;font, num, im-&gt;tColor); // Segmentation fault
  </code></pre>
  
  <p>If I print the 'num' variable to the output in both of those examples, they are 9554 (Keep in mind, it's not just 9554 doing this)</p>
  
  <p>EDIT:
  I just tried another approach, it segfaults as well</p>
  
  <pre><code>Uint16 num;
  memcpy(&amp;num, &amp;im-&gt;ch, sizeof(Uint16));
  fchar = TTF_RenderGlyph_Solid(com-&gt;font, num, im-&gt;tColor); // Segmentation fault
  </code></pre>
  
  <p>EDIT 2:
  This code does not crash</p>
  
  <pre><code>Uint16 num;
  memcpy(&amp;num, &amp;im-&gt;ch, sizeof(Uint16));
  
  if (num == 9554)
  {
      std::cout &lt;&lt; "9554" &lt;&lt; std::endl;
      num = 32;
  }
  
  fchar = TTF_RenderGlyph_Solid(com-&gt;font, num, im-&gt;tColor);
  </code></pre>
  
  <p>But this code does segfault</p>
  
  <pre><code>Uint16 num;
  memcpy(&amp;num, &amp;im-&gt;ch, sizeof(Uint16));
  
  if (num == 9554)
  {
      std::cout &lt;&lt; "9554" &lt;&lt; std::endl;
      num = 32;
      num = 9554;
  }
  
  fchar = TTF_RenderGlyph_Solid(com-&gt;font, num, im-&gt;tColor);
  </code></pre>