<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Wertebereich einer Enumeration]]></title><description><![CDATA[<p>Ich habe gerade gelesen, dass der Wertebereich einer Enumeration größer ist, als die Anzahl der Indizes. Stimmt das? Ist demnach folgendes erlaubt?</p>
<pre><code class="language-cpp">enum Foo { x=-7, y }; // Wertebereich: -8 bis +7
Foo f = static_cast&lt;Foo&gt;(5);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/299496/wertebereich-einer-enumeration</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 06:12:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/299496.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 12 Feb 2012 14:38:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wertebereich einer Enumeration on Sun, 12 Feb 2012 14:38:39 GMT]]></title><description><![CDATA[<p>Ich habe gerade gelesen, dass der Wertebereich einer Enumeration größer ist, als die Anzahl der Indizes. Stimmt das? Ist demnach folgendes erlaubt?</p>
<pre><code class="language-cpp">enum Foo { x=-7, y }; // Wertebereich: -8 bis +7
Foo f = static_cast&lt;Foo&gt;(5);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2180135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180135</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 12 Feb 2012 14:38:39 GMT</pubDate></item><item><title><![CDATA[Reply to Wertebereich einer Enumeration on Sun, 12 Feb 2012 15:09:53 GMT]]></title><description><![CDATA[<p>Gugelmoser schrieb:</p>
<blockquote>
<p>Ich habe gerade gelesen, dass der Wertebereich einer Enumeration größer ist, als die Anzahl der Indizes. Stimmt das? Ist demnach folgendes erlaubt?</p>
</blockquote>
<p>Ich verstehe so gar nicht, was Du meinst.</p>
<p>Gugelmoser schrieb:</p>
<blockquote>
<pre><code class="language-cpp">enum Foo { x=-7, y }; // Wertebereich: -8 bis +7
Foo f = static_cast&lt;Foo&gt;(5);
</code></pre>
</blockquote>
<p>Nein, das ist UB.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2180148</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180148</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Sun, 12 Feb 2012 15:09:53 GMT</pubDate></item><item><title><![CDATA[Reply to Wertebereich einer Enumeration on Sun, 12 Feb 2012 15:13:11 GMT]]></title><description><![CDATA[<p>Gugelmoser schrieb:</p>
<blockquote>
<p>Ich habe gerade gelesen, dass der Wertebereich einer Enumeration größer ist, als die Anzahl der Indizes. Stimmt das? Ist demnach folgendes erlaubt?</p>
<pre><code class="language-cpp">enum Foo { x=-7, y }; // Wertebereich: -8 bis +7
Foo f = static_cast&lt;Foo&gt;(5);
</code></pre>
</blockquote>
<p>Sofern dein Maschine 2er-Komplement benutzt, ist es -8 bis +7, sonst -7 bis +7; das ist also zulässig.<br />
Möglich ist sogar</p>
<pre><code class="language-cpp">enum Foo { x=-7, y }; // Wertebereich: -8 bis +7
Foo f = static_cast&lt;Foo&gt;(-10);
</code></pre>
<p>Allerdings ist das Ergebnis dieser Umwandlung unspezifiert (und muss nicht einmal im Bereich -8 bis +7 liegen).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2180151</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180151</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sun, 12 Feb 2012 15:13:11 GMT</pubDate></item><item><title><![CDATA[Reply to Wertebereich einer Enumeration on Sun, 12 Feb 2012 15:14:22 GMT]]></title><description><![CDATA[<p>Tachyon schrieb:</p>
<blockquote>
<p>Ich verstehe so gar nicht, was Du meinst.</p>
</blockquote>
<p>I a nit.</p>
<p>Laut Standard ist der underlying type <code>int</code> sofern nix anderes angegeben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2180152</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180152</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sun, 12 Feb 2012 15:14:22 GMT</pubDate></item><item><title><![CDATA[Reply to Wertebereich einer Enumeration on Sun, 12 Feb 2012 15:33:58 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>Sofern dein Maschine 2er-Komplement benutzt, ist es -8 bis +7, sonst -7 bis +7; das ist also zulässig.</p>
</blockquote>
<p>Danke, das wollt ich wissen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Swordfish schrieb:</p>
<blockquote>
<p>Laut Standard ist der underlying type <code>int</code> sofern nix anderes angegeben?</p>
</blockquote>
<blockquote>
<p>For an enumeration whose underlying type is not fixed, the underlying type is an integral type that can<br />
represent all the enumerator values defined in the enumeration. If no integral type can represent all the<br />
enumerator values, the enumeration is ill-formed. It is implementation-defined which integral type is used<br />
as the underlying type except that the underlying type shall not be larger than int unless the value of an<br />
enumerator cannot fit in an int or unsigned int. If the enumerator-list is empty, the underlying type is<br />
as if the enumeration had a single enumerator with value 0.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2180157</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2180157</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 12 Feb 2012 15:33:58 GMT</pubDate></item></channel></rss>