<?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[sizeof für Array dessen Größe von template Parameter bestimmt ist]]></title><description><![CDATA[<p>Hallo,</p>
<p>eine Frage an die C++ Experten. Ist folgender Code wirklich nicht C++ Standard-konform, oder spielt mir mein (Elsa) C++ Parser/Type-Checker einen Streich:</p>
<pre><code class="language-cpp">template &lt;int SIZE&gt;
  class Foo {
    private:
      int _x[SIZE];    
    public:
      Foo()
      {
        memset(_x,0,sizeof(_x));
      }
  };
</code></pre>
<p>Gcc übersetzt das anstandslos, Elsa meckert, dass sizeof nicht geht &quot;of a sizeless array&quot;. In dem Standarddokument was ich habe steht meines Erachtens nichts unter sizeof, was das verbietet, oder? Ich müsste das genau wissen.</p>
<p>(dass ich hier auch ohne weiteres: memset(_x,0,sizeof(int)*SIZE) schreiben könnte ist mir klar)</p>
<p>Vielen Dank für jede Hilfe im Voraus!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/206466/sizeof-für-array-dessen-größe-von-template-parameter-bestimmt-ist</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 12:12:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/206466.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Feb 2008 14:25:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to sizeof für Array dessen Größe von template Parameter bestimmt ist on Mon, 25 Feb 2008 14:25:54 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>eine Frage an die C++ Experten. Ist folgender Code wirklich nicht C++ Standard-konform, oder spielt mir mein (Elsa) C++ Parser/Type-Checker einen Streich:</p>
<pre><code class="language-cpp">template &lt;int SIZE&gt;
  class Foo {
    private:
      int _x[SIZE];    
    public:
      Foo()
      {
        memset(_x,0,sizeof(_x));
      }
  };
</code></pre>
<p>Gcc übersetzt das anstandslos, Elsa meckert, dass sizeof nicht geht &quot;of a sizeless array&quot;. In dem Standarddokument was ich habe steht meines Erachtens nichts unter sizeof, was das verbietet, oder? Ich müsste das genau wissen.</p>
<p>(dass ich hier auch ohne weiteres: memset(_x,0,sizeof(int)*SIZE) schreiben könnte ist mir klar)</p>
<p>Vielen Dank für jede Hilfe im Voraus!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1462511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1462511</guid><dc:creator><![CDATA[Nitpicker]]></dc:creator><pubDate>Mon, 25 Feb 2008 14:25:54 GMT</pubDate></item><item><title><![CDATA[Reply to sizeof für Array dessen Größe von template Parameter bestimmt ist on Mon, 25 Feb 2008 14:28:09 GMT]]></title><description><![CDATA[<p>Für einen statischen Array ist sizeof so definiert, wie du es haben willst und sollte d.h. standardknformes C++ sein <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1462514</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1462514</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Mon, 25 Feb 2008 14:28:09 GMT</pubDate></item><item><title><![CDATA[Reply to sizeof für Array dessen Größe von template Parameter bestimmt ist on Tue, 26 Feb 2008 07:58:51 GMT]]></title><description><![CDATA[<p>Vielen Dank für die schnelle Antwort, dann macht wohl Elsa an der Stelle unzureichendes checking.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1462996</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1462996</guid><dc:creator><![CDATA[Nitpicker]]></dc:creator><pubDate>Tue, 26 Feb 2008 07:58:51 GMT</pubDate></item></channel></rss>