<?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[Initialisierung mit Listen]]></title><description><![CDATA[<p>Hallo,</p>
<p>eine Frage zur &quot;Initialisierung mit Listen&quot; bei allgemeinen Konstruktoren: Ich habe eine Klasse:</p>
<pre><code class="language-cpp">// .H-file
#include &lt;iostream&gt;

//! Definition of a mesh class.
class mesh {
public:

  mesh();
  ~mesh();
...

private:

    int     numNodes_;
    int     numCells_;
    float*  materialvalueList_;
    CellPtr* cellList_;
    TCellPtr* tcellList_;
    EdgePtr* sourceList_;
};
</code></pre>
<p>und initialisiere diese:</p>
<pre><code class="language-cpp">// .CC-File
#include &quot;mesh.h&quot;
mesh::mesh() : 
                   numNodes_(0),
                   numCells_(0),               
                   cellList_(0),
                   tcellList_(0),
                   sourceList_(0)
{ };
</code></pre>
<p>wobei:</p>
<pre><code class="language-cpp">typedef EdgeT*  EdgePtr;
typedef CellT*  CellPtr;
typedef TCellT* TCellPtr;
</code></pre>
<p>definiert ist und die folgenden Klassen existieren:</p>
<pre><code class="language-cpp">//---------------------------
class EdgeT {
public:

  EdgeT();
  EdgeT( int index1, int index2 );
  EdgeT( int index[] );
  ~EdgeT();
...
private:
  int index_[2];
};

//---------------------------
class CellT {
public:

  virtual ~CellT() { }

protected:

  CellT() { }
};

//---------------------------
class TCellT : public CellT {
public:

  TCellT();
 ~TCellT() { }

private:

  int index_[4];
};
//---------------------------
</code></pre>
<p>NUN: Tritt das Problem auf, dass der Ausdruck :</p>
<p>sourceList_(0)</p>
<p>in der Initialisierungsliste des Konstruktors folgende Fehlermeldung bringt:</p>
<p>*** glibc detected *** ./exo: double free or corruption (!prev): 0x0000000000640010 ***<br />
======= Backtrace: =========<br />
/lib64/libc.so.6[0x2ac6e0d668fe]<br />
/lib64/libc.so.6(cfree+0x76)[0x2ac6e0d67f36]<br />
./exo(__gxx_personality_v0+0x233)[0x4019ab]<br />
/lib64/libc.so.6(__libc_start_main+0xf4)[0x2ac6e0d17ae4]<br />
./exo(__gxx_personality_v0+0xa1)[0x401819]<br />
======= Memory map: ========<br />
00400000-0043e000 r-xp 00000000 03:04 963722 /home/jochen/project/exodustest/exo<br />
0063e000-0063f000 r--p 0003e000 03:04 963722 /home/jochen/project/exodustest/exo<br />
0063f000-00640000 rw-p 0003f000 03:04 963722 /home/jochen/project/exodustest/exo<br />
00640000-006d2000 rw-p 00640000 00:00 0 [heap]<br />
2ac6e0379000-2ac6e0395000 r-xp 00000000 03:04 1093442 /lib64/ld-2.5.so<br />
2ac6e0395000-2ac6e0397000 rw-p 2ac6e0395000 00:00 0<br />
2ac6e03c9000-2ac6e03ca000 rw-p 2ac6e03c9000 00:00 0<br />
2ac6e0595000-2ac6e0597000 rw-p 0001c000 03:04 1093442 /lib64/ld-2.5.so<br />
2ac6e0597000-2ac6e067a000 r-xp 00000000 03:04 1260291 /usr/lib64/libstdc++.so.6.0.8<br />
2ac6e067a000-2ac6e087a000 ---p 000e3000 03:04 1260291 /usr/lib64/libstdc++.so.6.0.8<br />
2ac6e087a000-2ac6e0880000 r--p 000e3000 03:04 1260291 /usr/lib64/libstdc++.so.6.0.8<br />
2ac6e0880000-2ac6e0883000 rw-p 000e9000 03:04 1260291 /usr/lib64/libstdc++.so.6.0.8<br />
2ac6e0883000-2ac6e0895000 rw-p 2ac6e0883000 00:00 0<br />
2ac6e0895000-2ac6e08ea000 r-xp 00000000 03:04 1093457 /lib64/libm-2.5.so<br />
2ac6e08ea000-2ac6e0ae9000 ---p 00055000 03:04 1093457 /lib64/libm-2.5.so<br />
2ac6e0ae9000-2ac6e0aeb000 rw-p 00054000 03:04 1093457 /lib64/libm-2.5.so<br />
2ac6e0aeb000-2ac6e0af8000 r-xp 00000000 03:04 1093493 /lib64/libgcc_s.so.1<br />
2ac6e0af8000-2ac6e0cf7000 ---p 0000d000 03:04 1093493 /lib64/libgcc_s.so.1<br />
2ac6e0cf7000-2ac6e0cf9000 rw-p 0000c000 03:04 1093493 /lib64/libgcc_s.so.1<br />
2ac6e0cf9000-2ac6e0cfa000 rw-p 2ac6e0cf9000 00:00 0<br />
2ac6e0cfa000-2ac6e0e33000 r-xp 00000000 03:04 1093449 /lib64/libc-2.5.so<br />
2ac6e0e33000-2ac6e1032000 ---p 00139000 03:04 1093449 /lib64/libc-2.5.so<br />
2ac6e1032000-2ac6e1035000 r--p 00138000 03:04 1093449 /lib64/libc-2.5.so<br />
2ac6e1035000-2ac6e1037000 rw-p 0013b000 03:04 1093449 /lib64/libc-2.5.so<br />
2ac6e1037000-2ac6e103d000 rw-p 2ac6e1037000 00:00 0<br />
2ac6e4000000-2ac6e4021000 rw-p 2ac6e4000000 00:00 0<br />
2ac6e4021000-2ac6e8000000 ---p 2ac6e4021000 00:00 0<br />
7fffca71a000-7fffca731000 rw-p 7fffca71a000 00:00 0 [stack]<br />
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vdso]<br />
Abgebrochen</p>
<p>warum kann ich &quot;cellList_(0),tcellList_(0),&quot; initialisieren aber &quot;sourceList_(0)&quot; nicht? Was für Regeln gelten dabei?<br />
Danke für Hilfe!</p>
<p>Jo</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/191456/initialisierung-mit-listen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 26 Sep 2026 00:31:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/191456.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 03 Sep 2007 12:57:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Initialisierung mit Listen on Mon, 03 Sep 2007 13:16:37 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>eine Frage zur &quot;Initialisierung mit Listen&quot; bei allgemeinen Konstruktoren: Ich habe eine Klasse:</p>
<pre><code class="language-cpp">// .H-file
#include &lt;iostream&gt;

//! Definition of a mesh class.
class mesh {
public:

  mesh();
  ~mesh();
...

private:

    int     numNodes_;
    int     numCells_;
    float*  materialvalueList_;
    CellPtr* cellList_;
    TCellPtr* tcellList_;
    EdgePtr* sourceList_;
};
</code></pre>
<p>und initialisiere diese:</p>
<pre><code class="language-cpp">// .CC-File
#include &quot;mesh.h&quot;
mesh::mesh() : 
                   numNodes_(0),
                   numCells_(0),               
                   cellList_(0),
                   tcellList_(0),
                   sourceList_(0)
{ };
</code></pre>
<p>wobei:</p>
<pre><code class="language-cpp">typedef EdgeT*  EdgePtr;
typedef CellT*  CellPtr;
typedef TCellT* TCellPtr;
</code></pre>
<p>definiert ist und die folgenden Klassen existieren:</p>
<pre><code class="language-cpp">//---------------------------
class EdgeT {
public:

  EdgeT();
  EdgeT( int index1, int index2 );
  EdgeT( int index[] );
  ~EdgeT();
...
private:
  int index_[2];
};

//---------------------------
class CellT {
public:

  virtual ~CellT() { }

protected:

  CellT() { }
};

//---------------------------
class TCellT : public CellT {
public:

  TCellT();
 ~TCellT() { }

private:

  int index_[4];
};
//---------------------------
</code></pre>
<p>NUN: Tritt das Problem auf, dass der Ausdruck :</p>
<p>sourceList_(0)</p>
<p>in der Initialisierungsliste des Konstruktors folgende Fehlermeldung bringt:</p>
<p>*** glibc detected *** ./exo: double free or corruption (!prev): 0x0000000000640010 ***<br />
======= Backtrace: =========<br />
/lib64/libc.so.6[0x2ac6e0d668fe]<br />
/lib64/libc.so.6(cfree+0x76)[0x2ac6e0d67f36]<br />
./exo(__gxx_personality_v0+0x233)[0x4019ab]<br />
/lib64/libc.so.6(__libc_start_main+0xf4)[0x2ac6e0d17ae4]<br />
./exo(__gxx_personality_v0+0xa1)[0x401819]<br />
======= Memory map: ========<br />
00400000-0043e000 r-xp 00000000 03:04 963722 /home/jochen/project/exodustest/exo<br />
0063e000-0063f000 r--p 0003e000 03:04 963722 /home/jochen/project/exodustest/exo<br />
0063f000-00640000 rw-p 0003f000 03:04 963722 /home/jochen/project/exodustest/exo<br />
00640000-006d2000 rw-p 00640000 00:00 0 [heap]<br />
2ac6e0379000-2ac6e0395000 r-xp 00000000 03:04 1093442 /lib64/ld-2.5.so<br />
2ac6e0395000-2ac6e0397000 rw-p 2ac6e0395000 00:00 0<br />
2ac6e03c9000-2ac6e03ca000 rw-p 2ac6e03c9000 00:00 0<br />
2ac6e0595000-2ac6e0597000 rw-p 0001c000 03:04 1093442 /lib64/ld-2.5.so<br />
2ac6e0597000-2ac6e067a000 r-xp 00000000 03:04 1260291 /usr/lib64/libstdc++.so.6.0.8<br />
2ac6e067a000-2ac6e087a000 ---p 000e3000 03:04 1260291 /usr/lib64/libstdc++.so.6.0.8<br />
2ac6e087a000-2ac6e0880000 r--p 000e3000 03:04 1260291 /usr/lib64/libstdc++.so.6.0.8<br />
2ac6e0880000-2ac6e0883000 rw-p 000e9000 03:04 1260291 /usr/lib64/libstdc++.so.6.0.8<br />
2ac6e0883000-2ac6e0895000 rw-p 2ac6e0883000 00:00 0<br />
2ac6e0895000-2ac6e08ea000 r-xp 00000000 03:04 1093457 /lib64/libm-2.5.so<br />
2ac6e08ea000-2ac6e0ae9000 ---p 00055000 03:04 1093457 /lib64/libm-2.5.so<br />
2ac6e0ae9000-2ac6e0aeb000 rw-p 00054000 03:04 1093457 /lib64/libm-2.5.so<br />
2ac6e0aeb000-2ac6e0af8000 r-xp 00000000 03:04 1093493 /lib64/libgcc_s.so.1<br />
2ac6e0af8000-2ac6e0cf7000 ---p 0000d000 03:04 1093493 /lib64/libgcc_s.so.1<br />
2ac6e0cf7000-2ac6e0cf9000 rw-p 0000c000 03:04 1093493 /lib64/libgcc_s.so.1<br />
2ac6e0cf9000-2ac6e0cfa000 rw-p 2ac6e0cf9000 00:00 0<br />
2ac6e0cfa000-2ac6e0e33000 r-xp 00000000 03:04 1093449 /lib64/libc-2.5.so<br />
2ac6e0e33000-2ac6e1032000 ---p 00139000 03:04 1093449 /lib64/libc-2.5.so<br />
2ac6e1032000-2ac6e1035000 r--p 00138000 03:04 1093449 /lib64/libc-2.5.so<br />
2ac6e1035000-2ac6e1037000 rw-p 0013b000 03:04 1093449 /lib64/libc-2.5.so<br />
2ac6e1037000-2ac6e103d000 rw-p 2ac6e1037000 00:00 0<br />
2ac6e4000000-2ac6e4021000 rw-p 2ac6e4000000 00:00 0<br />
2ac6e4021000-2ac6e8000000 ---p 2ac6e4021000 00:00 0<br />
7fffca71a000-7fffca731000 rw-p 7fffca71a000 00:00 0 [stack]<br />
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vdso]<br />
Abgebrochen</p>
<p>warum kann ich &quot;cellList_(0),tcellList_(0),&quot; initialisieren aber &quot;sourceList_(0)&quot; nicht? Was für Regeln gelten dabei?<br />
Danke für Hilfe!</p>
<p>Jo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357878</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357878</guid><dc:creator><![CDATA[NoPanic2007]]></dc:creator><pubDate>Mon, 03 Sep 2007 13:16:37 GMT</pubDate></item><item><title><![CDATA[Reply to Initialisierung mit Listen on Mon, 03 Sep 2007 13:00:43 GMT]]></title><description><![CDATA[<p>Reduzier das Beispiel mal auf ein Minimum - tritt der Fehler bereits im Ctor auf? Und hast du den Fehler schon, wenn du das Objekt anlegst und sofort aus dem Scope fallen lässt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357883</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357883</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 03 Sep 2007 13:00:43 GMT</pubDate></item><item><title><![CDATA[Reply to Initialisierung mit Listen on Mon, 03 Sep 2007 13:04:58 GMT]]></title><description><![CDATA[<p>Zuerst einmal: nutze das Syntax-Highlighting, dann ist dein Code deutlich einffacher zu lesen.<br />
Dann: Du initialisierst einen Pointer auf TCellPtr, also einen Pointer auf einen Pointer mit 0 - das duerfte kein Problem sein. Der Fehler duerfte also ein etwas subtilerer Sein als dass einfach die Initialisierung dir so eine Fehlermeldung beschert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357890</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357890</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 03 Sep 2007 13:04:58 GMT</pubDate></item><item><title><![CDATA[Reply to Initialisierung mit Listen on Mon, 03 Sep 2007 13:18:22 GMT]]></title><description><![CDATA[<p>Sobald ich &quot;sourceList_(0)&quot; auskommentiere gibt es kein Problem mehr!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357913</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357913</guid><dc:creator><![CDATA[NoPanic2007]]></dc:creator><pubDate>Mon, 03 Sep 2007 13:18:22 GMT</pubDate></item><item><title><![CDATA[Reply to Initialisierung mit Listen on Mon, 03 Sep 2007 13:23:47 GMT]]></title><description><![CDATA[<p>Kommentier mal sämtlichen Code aus der sourceList_ benutzt und dann probiers nochmal.<br />
Meine Vermutung ist, dass der Code mit auskommentiertem sourceList_(0) nur deswegen läuft weil die Variable dadurch einen Wert != 0 hat und es so scheint als würde es funktionieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357920</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357920</guid><dc:creator><![CDATA[lolz]]></dc:creator><pubDate>Mon, 03 Sep 2007 13:23:47 GMT</pubDate></item><item><title><![CDATA[Reply to Initialisierung mit Listen on Mon, 03 Sep 2007 13:36:08 GMT]]></title><description><![CDATA[<p>Ich habe alles was mit sourceList_ zutun hat auskommentiert.<br />
Nur in &quot;private&quot; nicht! dann funktioniert es (keine Fehlermeldung).</p>
<p>Sobald ich initialisiere sourceList_(0) kommt die Fehlermeldung!</p>
<p>Wenn sourceList_(0) nicht initialisiere ist, dafür aber der Quellcode mit sourceList drin bleibt, gibt es einen Speicherzugriffsfehler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357925</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357925</guid><dc:creator><![CDATA[NoPanic2007]]></dc:creator><pubDate>Mon, 03 Sep 2007 13:36:08 GMT</pubDate></item><item><title><![CDATA[Reply to Initialisierung mit Listen on Mon, 03 Sep 2007 13:40:16 GMT]]></title><description><![CDATA[<p>Das hoert sich so an als ob source_list irgendwo benutzt wird, wo erwartet wird, dass es auf ein gueltifes Objekt verweist. Ist es 0, dann gibts die Fehlermeldung, ist es nicht 0, wird dereferenziert und BUMM... Hats du evtl vergessen die Zugehoerige Ressource zu initialisieren bzw. sourceList darauf verweisen zu lassen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357937</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357937</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 03 Sep 2007 13:40:16 GMT</pubDate></item><item><title><![CDATA[Reply to Initialisierung mit Listen on Mon, 03 Sep 2007 14:09:23 GMT]]></title><description><![CDATA[<p>sourceList_ verweist im Laufe des Programms auf ein weiteres EdgePtr Objekt. Das funktioniert aber!<br />
Das Problem muss doch schon vorher liegen?! Wenn alles (mit sourceList und was darauf referenziert oder auf das referenziert wird) auskommentiert ist entsteht schon der Speicherzugriffsfehler. Alleine durch das Initialisieren! ???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357966</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357966</guid><dc:creator><![CDATA[NoPanic2007]]></dc:creator><pubDate>Mon, 03 Sep 2007 14:09:23 GMT</pubDate></item><item><title><![CDATA[Reply to Initialisierung mit Listen on Mon, 03 Sep 2007 14:22:08 GMT]]></title><description><![CDATA[<p>kann es mit abstracten klassen und &quot;virtual&quot; zutun haben?</p>
<p>EdgeT ist nicht abstract (für sourceList_),<br />
CellT ist abstract (für cellList_)!<br />
HCellT ist eine abgeleitet Klasse...?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357980</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357980</guid><dc:creator><![CDATA[NoPanic2007]]></dc:creator><pubDate>Mon, 03 Sep 2007 14:22:08 GMT</pubDate></item><item><title><![CDATA[Reply to Initialisierung mit Listen on Tue, 04 Sep 2007 08:56:57 GMT]]></title><description><![CDATA[<p>OKAY!</p>
<p>Ich hatte ein Warning ignoriert. Dabei ging es um die Reihenfolge der Initialisierung. Auskommentieren bzw, Beachten der Reihenfolge hat das Problem gelöst.</p>
<p>Danke für die Kommentare und den Beistand!<br />
Jo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1357993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1357993</guid><dc:creator><![CDATA[NoPanic2007]]></dc:creator><pubDate>Tue, 04 Sep 2007 08:56:57 GMT</pubDate></item></channel></rss>