Bug 95028 - ICE in g++ (Arch Linux 9.3.0-1) 9.3.0 with captured OMP reduce clause in lambda
Summary: ICE in g++ (Arch Linux 9.3.0-1) 9.3.0 with captured OMP reduce clause in lambda
Status: RESOLVED DUPLICATE of bug 93931
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: c++-lambda, ice-on-valid-code, openmp
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2020-05-09 22:44 UTC by fytch
Modified: 2022-03-11 00:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 8.5.0, 9.4.0
Known to fail: 8.4.0, 9.3.0
Last reconfirmed:


Attachments
Code that causes the ICE (same as in the comment) (136 bytes, text/plain)
2020-05-09 22:44 UTC, fytch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description fytch 2020-05-09 22:44:21 UTC
Created attachment 48491 [details]
Code that causes the ICE (same as in the comment)

Description:
GCC seems to crash when writing this OpenMP clause within a lambda. Writing the loop outside the lambda is fine and defining the variable sum inside the lambda is also fine but this combination seems to crash GCC.

Code:
int main() {
    double sum;
    const auto task = [&] {
        #pragma omp parallel for reduction(+: sum)
        for(int i = 0; i < 1; ++i)
            sum += 1;
    };
    task();
}

Compiled with:
g++ main.cpp -fopenmp

Output:
during RTL pass: expand
main.cpp: In lambda function:
main.cpp:4:17: internal compiler error: in make_decl_rtl, at varasm.c:1340
    4 |         #pragma omp parallel for reduction(+: sum)
      |                 ^~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.

Output of g++ -v:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-pkgversion='Arch Linux 9.3.0-1' --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-shared --enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp --enable-cet=auto gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
gcc version 9.3.0 (Arch Linux 9.3.0-1)
Comment 1 fytch 2020-05-24 17:37:12 UTC
Seems to be fixed in GCC g++ 10.1.0
Comment 2 Andrew Pinski 2021-10-01 07:14:10 UTC
Dup of bug 93931.

*** This bug has been marked as a duplicate of bug 93931 ***