title: C: How to get rid of conversion error?
body: <p>I have a project which uses gcc version 4.6.3, and I'm forced to compile with "-Wall -Werror -Wconversion".  The following simple example shows an error I can't get rid of:</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  
  int main(void) {
    uint32_t u = 0;
    char c = 1;
  
    u += c;
    return (int)u;
  }
  </code></pre>
  
  <p>Compiling it with the above flags gives:</p>
  
  <pre><code>test.c:7:8: error: conversion to ‘uint32_t’ from ‘char’ may change the sign of the result [-Werror=sign-conversion]
  </code></pre>
  
  <p>Ok, fine.  Just add a typecast, right?  Nope.  Changing line 7 to <code>u += (uint32_t)c</code> does not make the error go away.  Even changing it to <code>u = u + (uint32_t)c</code> does not make it go away.</p>
  
  <p>Is it possible to fix this?</p>
  
  <p>Please note that the "char" is coming from a string, so I don't have the option to change its type.</p>