+= operation overloading, self concatenation
<p>First of all forgive me, but the code was too long and copied from code::blocks, so there was no indentation, I used pastebin, this is the class:
<a href="http://pastebin.com/auY5PnFw" rel="nofollow">http://pastebin.com/auY5PnFw</a>
In this class I have a list, the += operator overloading is here:</p>

<pre><code>List&lt;T&gt;&amp; operator+= (List&lt;T&gt;&amp; l)
{
    List&lt;T&gt;* ptr;
    ptr=l.next;
    while(ptr!=&amp;l)
    {
        this-&gt;push(*ptr-&gt;info);
        ptr=ptr-&gt;next;
    }
    return (*this);
}
</code></pre>

<p>The problem is with self concatenation, let's say that I have a List l1, and this list has some values inside it.If I say: l1+=l1 , trying to compile a program I see that the program goes into an infinite loop.
I tried to reason over this,since the arguments is l1, called by reference, is valid that this==&amp;l.
So ptr point to l.next, but also to this->next.
I read all info and push values into the list, I don't know why it goes into an infinite loop,I have no idea.</p>
