There are two problems with list_remove_elem function in objc/objc-list.h file: - function dumps core when remove first element of the list, - if element is in the list more than once and copy of the element are one by one they do not be removed all.
struct objc_list *list = 0; int elem_1 = 1; int elem_2 = 2; int elem_3 = 3; list = list_cons((void *)&elem_1, list); list = list_cons((void *)&elem_2, list); list = list_cons((void *)&elem_2, list); list = list_cons((void *)&elem_2, list); list = list_cons((void *)&elem_3, list); list_remove_elem(&list, (void *)&elem_2); // Remove only 2 elem_2! list_remove_elem(&list, (void *)&elem_1); // Core dumps! After list_remove_head should have not changed pointer to tail. The following patch repair both problems. --- /usr/include/objc/objc-list.h 2006-04-20 11:55:22.000000000 +0200 +++ objc-list.h 2009-01-16 21:05:04.000000000 +0100 @@ -106,7 +106,11 @@ { while (*list) { if ((*list)->head == elem) - list_remove_head(list); + { + list_remove_head(list); + continue; + } + list = &((*list)->tail); } } -- Summary: Two problem in objc-list.h in list_remove_elem Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libobjc AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bartosz dot kuzma at gmail dot com GCC host triplet: i386--netbsdelf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38881