Note that there are some explanatory texts on larger screens.

plurals
  1. POC++Can't find error, double free or corruption (fasttop)
    primarykey
    data
    text
    <p>I am getting the following output from my program:</p> <pre><code>$ ./list Enter list 1: [1,2,3,4] [ Enter list 2: [2,5,8,0] [ [1,2,3,4] [1,2,3,4] *** Error in `./list': double free or corruption (fasttop): 0x0000000000f85100 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x80a46)[0x7fa0368d6a46] ./list[0x400d5f] ./list[0x400c62] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fa036877ea5] ./list[0x400ae9] ======= Memory map: ======== 00400000-00402000 r-xp 00000000 ca:01 410613 /home/ubuntu/list </code></pre> <p>...</p> <pre><code>ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] the endAborted (core dumped) </code></pre> <p>This is what I have in main:</p> <pre><code>int main(){ pennlist::List l1,l2; cout&lt;&lt;"Enter list 1:\t"; cin&gt;&gt;l1; cout&lt;&lt;"Enter list 2:\t"; cin&gt;&gt;l2; cout&lt;&lt;l1&lt;&lt;endl&lt;&lt;l2&lt;&lt;endl; cout&lt;&lt;"the end"; } </code></pre> <p>And this this is the overloaded >> operator. </p> <pre><code>istream&amp; operator &gt;&gt;(istream&amp; ins, List&amp; write_me){ char discard; write_me.head = new node; write_me.current = write_me.head; node* temp = write_me.head; ins&gt;&gt;discard;//get [ cout&lt;&lt;discard&lt;&lt;endl; while(discard != ']'){ ins&gt;&gt;temp-&gt;data; write_me.count += 1; temp-&gt;to_tail = new node; temp-&gt;to_head = temp; temp = temp-&gt;to_tail; ins&gt;&gt;discard; //get , or ] } write_me.tail = temp; temp = NULL; return ins; } </code></pre> <p>I have overloaded the =, ~ and copy ctr as well and get the same error before and after adding these functions.</p> <p>I can't figure out how to resolve this error, please help.</p> <p>EDIT</p> <pre><code>Here is the code for the destructor: ~List{ delete head; delete current; delete tail; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload