title: What does "representable" mean in C11?
body: <p>According to C11 <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf" rel="nofollow">WG14 draft version N1570</a>:</p>
  
  <blockquote>
    <p>The header <code>&lt;ctype.h&gt;</code> declares several functions useful for classifying
    and mapping characters. In all cases the argument is an <code>int</code>, the
    value of which shall be representable as an <code>unsigned char</code> or shall
    equal the value of the macro <code>EOF</code>. If the argument has any other value,
    the behavior is undefined.</p>
  </blockquote>
  
  <p>Is it undefined behaviour?:</p>
  
  <pre><code>#include &lt;ctype.h&gt;
  #include &lt;limits.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void) {
    char c = CHAR_MIN; /* let assume that char is signed and CHAR_MIN &lt; 0 */
    return isspace(c) ? EXIT_FAILURE : EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>Does the standard allow to pass <code>char</code> to <code>isspace()</code> (<code>char</code> to <code>int</code>)? In other words, is <code>char</code> after conversion to <code>int</code> <em>representable</em> as an <code>unsigned char</code>?</p>
  
  <hr>
  
  <p>Here's how <a href="http://en.wiktionary.org/wiki/representable" rel="nofollow">wiktionary defines "representable"</a>:</p>
  
  <blockquote>
    <p>Capable of being represented.</p>
  </blockquote>
  
  <p>Is <code>char</code> capable of being represented as <code>unsigned char</code>? <strong>Yes</strong>. §6.2.6.1/4:</p>
  
  <blockquote>
    <p>Values stored in non-bit-field objects of any other object type
    consist of <em>n</em> <code>×</code> <strong><code>CHAR_BIT</code></strong> bits, where <em>n</em> is the size of an object of that
    type, in bytes. The value may be copied into an object of type
    <strong>unsigned char</strong> [<em>n</em>] (e.g., by <strong>memcpy</strong>); the resulting set of bytes is
    called the <em>object representation</em> of the value.</p>
  </blockquote>
  
  <p><code>sizeof(char) == 1</code> therefore its object representation is <code>unsigned char[1]</code> i.e., <code>char</code> is capable of being represented as an <code>unsigned char</code>. Where am I wrong?</p>
  
  <p>Concrete example, I can represent <code>[-2, -1, 0, 1]</code> as <code>[0, 1, 2, 3]</code>. If I can't then why?</p>
  
  <hr>
  
  <p>Related: According to §6.3.1.3 <code>isspace((unsigned char)c)</code> is portable if <code>INT_MAX &gt;= UCHAR_MAX</code> otherwise it is implementation-defined.</p>