https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86291
Bug ID: 86291 Summary: OpenMP incorrect for-loop collapsing with iterators and at least 5 nested loops Product: gcc Version: 8.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: bonjour at matteodelabre dot me CC: jakub at gcc dot gnu.org Target Milestone: --- Created attachment 44315 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44315&action=edit Preprocessor output When collapsing at least 5 nested for loops with the collapse() clause in a `for` pragma, the body of the loop never executes. In the testcase, 5 for loops on trivial iterators are nested. These iterators only yield one value, such that the innermost statement should execute exactly once. When compiled without the -fopenmp flag, the program exhibits correct behaviour and we see one line printed on standard output. When compiled with the -fopenmp flag, the body of the loop never executes and the output stays blank. This only happens when all of the loop variables are iterators and there is at least 5 levels of nesting. If any of the loops is changed to operate on non-iterator values (such as plain integers) or if the nesting is reduced below 5 levels, the statement executes. g++ -v info: Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/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-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --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 Thread model: posix gcc version 8.1.1 20180531 (GCC)