This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61421] Invalid -O2 optimization breaks program
- From: "mimamer at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Jun 2014 16:52:21 +0000
- Subject: [Bug c++/61421] Invalid -O2 optimization breaks program
- Auto-submitted: auto-generated
- References: <bug-61421-4 at http dot gcc dot gnu dot org/bugzilla/>
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.