https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61421
--- Comment #2 from mimamer at gmail dot com ---
Turns out the problems arise in different places but only in the
list2::dequeue() function:
inline T *dequeue() {
//asm volatile("":::"memory");
T *head = anchor.next;
anchor.next = head->next;
head->next->prev = (T *)&anchor;
#if 1//(defined(DEBUG) || defined(_DEBUG)) && !defined(NDEBUG)
if ( head != (T *)&anchor )
head->prev = head->next = NULL;
#endif
return head;
};
Uncommenting the memory barrier resolves all issues.