https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61571

            Bug ID: 61571
           Summary: bad aliasing --> wrong FRE
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xinliangli at gmail dot com

Compile the attached source with -m32 -std=c++11 -O2 on x86, the program will
crash. It runs fine with -m32 -std=c++11 -O2 -fno-tree-pre -fno-tree-fre.

(same failure is also observed on arm target).

The bad FRE happens in list<int>::merge function. list<int>::splice needs to be
inlined to trigger the bad CSE.

The problematic CSE is this one:

list<int>::merge (...)
 {

     if (this != &__c)
    {
        iterator __f1 = begin();   
        iterator __e1 = end();
        iterator __f2 = __c.begin(); // this one
        ...
        while (...)
        {
        }

       // inline instance of splice:


    if (!__c.empty())
    {
        __node_pointer __f = __c.__end_.__next_;   // and this one
        __node_pointer __l = __c.__end_.__prev_;
        base::__unlink_nodes(__f, __l);
        __link_nodes(__p.__ptr_, __f, __l);
        base::__sz() += __c.__sz();
        __c.__sz() = 0;
    }

Note begin() method accesses __c.__end_.__next_.

Reply via email to