Found that the bug was actually the incorrect typecast to Link<int,int>* of *(list::iterator). All the instances were replaced and now things are working fine.