[Bug c++/93931] New: ICE using lambda capture in openMP parallel for reduction

Peter.Georg at physik dot uni-regensburg.de gcc-bugzilla@gcc.gnu.org
Tue Feb 25 18:22:00 GMT 2020


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

            Bug ID: 93931
           Summary: ICE using lambda capture in openMP parallel for
                    reduction
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Peter.Georg at physik dot uni-regensburg.de
  Target Milestone: ---

Created attachment 47909
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47909&action=edit
Source

The following (and attached) code fails to compile with any GCC >= 8 when
openMP is enabled. GCC compiles the code, but the result is wrong. Any tested
clang version compiles the code with no errors and the result is right.

#include <iostream>

int main()
{
    int score = 0;
    [&score]()
    {
#pragma omp parallel for reduction(+ : score)
        for(int i= 0; i < 1000; ++i)
        {
            score += i;
        }
    }();

    std::cout << score << std::endl;

    return score;
}

Error:
during RTL pass: expand
omp.cpp: In lambda function:
omp.cpp:6:9: internal compiler error: in make_decl_rtl, at varasm.c:1340
    6 | #pragma omp parallel for reduction(+ : score)
      |


More information about the Gcc-bugs mailing list