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

            Bug ID: 119480
           Summary: Wrong code generated in simple program that uses
                    LLVM::map_to_vector
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Mark_B53 at yahoo dot com
  Target Milestone: ---

#include <llvm/ADT/SmallVectorExtras.h>

int main()
{
    int data[] = {1,2,3,4,5};
    bool changed = false;
    auto fn = [&](int val) { changed = true; return val; };
    auto out = llvm::map_to_vector(data, fn);
    return changed;
}

Program should print 1.  However, on GCC 12.* and 13.* for -O1 & -O2, the
output is 0.

// Summary of Results
//           -O0    -O1/2  -O3
// 11.*      pass   pass   pass
// 12.*      pass   FAIL   pass 
// 13.*      pass   FAIL   pass
// 14.*      pass   pass   pass

Reply via email to