Affects versions down to r6 : $ cat z1.c void f (int n) { int i; #pragma omp for ordered(1) for (i = 0; i < 8; i += n) for (;;); } $ gcc-11-20201206 -c z1.c -fopenmp during GIMPLE pass: ompexp z1.c: In function 'f': z1.c:4:11: internal compiler error: Segmentation fault 4 | #pragma omp for ordered(1) | ^~~ 0xd2670f crash_signal ../../gcc/toplev.c:327 0x1880c99 bb_seq_addr ../../gcc/gimple.h:1764 0x1880c99 gsi_last_bb ../../gcc/gimple-iterator.h:164 0x1880c99 expand_omp_for_generic ../../gcc/omp-expand.c:4307 0x18852c9 expand_omp_for ../../gcc/omp-expand.c:8107 0x188616a expand_omp ../../gcc/omp-expand.c:9901 0x188802d execute_expand_omp ../../gcc/omp-expand.c:10133
Created attachment 49712 [details] gcc11-pr98205.patch Untested fix.
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:a2a17ae7d85e420db5fe0c7ab2f59a470e2c7a78 commit r11-5897-ga2a17ae7d85e420db5fe0c7ab2f59a470e2c7a78 Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Dec 10 11:07:07 2020 +0100 openmp: Fix ICE with broken doacross loop [PR98205] If the loop body doesn't ever continue, we don't have a bb to insert the updates. Fixed by not adding them at all in that case. 2020-12-10 Jakub Jelinek <jakub@redhat.com> PR middle-end/98205 * omp-expand.c (expand_omp_for_generic): Fix up broken_loop handling. * c-c++-common/gomp/doacross-4.c: New test.
The releases/gcc-10 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:c925d4cebf817905c237aa2d93887f254b4a74f4 commit r10-9219-gc925d4cebf817905c237aa2d93887f254b4a74f4 Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Dec 10 11:07:07 2020 +0100 openmp: Fix ICE with broken doacross loop [PR98205] If the loop body doesn't ever continue, we don't have a bb to insert the updates. Fixed by not adding them at all in that case. 2020-12-10 Jakub Jelinek <jakub@redhat.com> PR middle-end/98205 * omp-expand.c (expand_omp_for_generic): Fix up broken_loop handling. * c-c++-common/gomp/doacross-4.c: New test. (cherry picked from commit a2a17ae7d85e420db5fe0c7ab2f59a470e2c7a78)
The releases/gcc-9 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:6f0a0d1c2bb7ad2020852ccf14ca86967ddb134a commit r9-9400-g6f0a0d1c2bb7ad2020852ccf14ca86967ddb134a Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Dec 10 11:07:07 2020 +0100 openmp: Fix ICE with broken doacross loop [PR98205] If the loop body doesn't ever continue, we don't have a bb to insert the updates. Fixed by not adding them at all in that case. 2020-12-10 Jakub Jelinek <jakub@redhat.com> PR middle-end/98205 * omp-expand.c (expand_omp_for_generic): Fix up broken_loop handling. * c-c++-common/gomp/doacross-4.c: New test. (cherry picked from commit c925d4cebf817905c237aa2d93887f254b4a74f4)
The releases/gcc-8 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:a66e756ea9cf1ce8f2c73bd29bfe7ed785fae89a commit r8-10868-ga66e756ea9cf1ce8f2c73bd29bfe7ed785fae89a Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Dec 10 11:07:07 2020 +0100 openmp: Fix ICE with broken doacross loop [PR98205] If the loop body doesn't ever continue, we don't have a bb to insert the updates. Fixed by not adding them at all in that case. 2020-12-10 Jakub Jelinek <jakub@redhat.com> PR middle-end/98205 * omp-expand.c (expand_omp_for_generic): Fix up broken_loop handling. * c-c++-common/gomp/doacross-4.c: New test. (cherry picked from commit c925d4cebf817905c237aa2d93887f254b4a74f4)
Fixed.