This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/61421] Invalid -O2 optimization breaks program


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]