Is it legal to use char overflow in C++ code
<p>Good day, colleagues!</p>

<p>I need to obtain cyclic series on successive numbers from 0 to 255. Is it legal to use unsigned char overflow like this:</p>

<pre><code>unsigned char test_char = 0;

while (true) {
    std::cout &lt;&lt; test_char++ &lt;&lt; " ";
}
</code></pre>

<p>Or will be more safely to use this code:</p>

<pre><code>int test_int = 0;

while (true) {
    std::cout &lt;&lt; test_int++ % 256 &lt;&lt; " ";
}
</code></pre>

<p>Of course, in real code there will be reasonable condition instead of while (true).</p>
