public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/105242] New: [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147
@ 2022-04-12 16:43 burnus at gcc dot gnu.org
  2022-04-13  6:46 ` [Bug fortran/105242] " burnus at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-04-12 16:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105242
           Summary: [OpenMP] ICE with EXIT in collapsed loop: in
                    gfc_trans_exit, at fortran/trans-stmt.cc:6147
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, openmp
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

The following code (reduced code from a real-world project) gives an ICE but
compiles with other vendors' compilers. It fails with GCC 10, 11 and trunk/12
with:

    8 |      if (kk == 7) exit
      |                      1
internal compiler error: in gfc_trans_exit, at fortran/trans-stmt.cc:6147
0x69734b gfc_trans_exit(gfc_code*)
        ../../repos/gcc/gcc/fortran/trans-stmt.cc:6147
0xa17360 trans_code
        ../../repos/gcc/gcc/fortran/trans.cc:1947
0xa9e4b5 gfc_trans_if_1
        ../../repos/gcc/gcc/fortran/trans-stmt.cc:1484
0xaa84cf gfc_trans_if(gfc_code*)
        ../../repos/gcc/gcc/fortran/trans-stmt.cc:1516
0xa17563 trans_code
        ../../repos/gcc/gcc/fortran/trans.cc:2004
0xa8ad58 gfc_trans_omp_code
        ../../repos/gcc/gcc/fortran/trans-openmp.cc:4399
0xa9a6aa gfc_trans_omp_do
        ../../repos/gcc/gcc/fortran/trans-openmp.cc:5381




!$omp target parallel do simd collapse(3)
do ii = i1, i2
 do jj = j1, j2
   do kk = k1, k2
     if (kk > 5) then
       k = 0
     end if
     if (kk == 7) exit
  end do
  end do
end do
!$omp end target parallel do simd
end

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/105242] [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147
  2022-04-12 16:43 [Bug fortran/105242] New: [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147 burnus at gcc dot gnu.org
@ 2022-04-13  6:46 ` burnus at gcc dot gnu.org
  2022-04-13 11:25 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-04-13  6:46 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |accepts-invalid, diagnostic

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Actually, the EXIT does not make sense. There is:

Fortran
"final-loop-body must not contain any EXIT statement that would cause the
termination of the5
innermost loop."

→ Accepts invalid for C/C++/Fortran

I thought it did work in C/C++, but I messed up.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/105242] [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147
  2022-04-12 16:43 [Bug fortran/105242] New: [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147 burnus at gcc dot gnu.org
  2022-04-13  6:46 ` [Bug fortran/105242] " burnus at gcc dot gnu.org
@ 2022-04-13 11:25 ` jakub at gcc dot gnu.org
  2022-04-13 14:58 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-13 11:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Why do you say accepts invalid for C/C++?
void
foo (int i1, int i2, int j1, int j2, int k1, int k2)
{
  int k = 1;
  #pragma omp target parallel for simd collapse(3) firstprivate (k)
  for (int ii = i1; ii <= i2; ++ii)
    for (int jj = j1; jj <= j2; ++jj)
      for (int kk = k1; kk <= k2; ++kk)
        {
          if (kk > 5)
            k = 0;
          if (kk == 7)
            break;
        }
}
is certainly rejected:
pr105242.c: In function ‘foo’:
pr105242.c:13:13: error: break statement used with OpenMP for loop
   13 |             break;
      |             ^~~~~
by both C and C++ (all the way back to GCC 6).

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/105242] [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147
  2022-04-12 16:43 [Bug fortran/105242] New: [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147 burnus at gcc dot gnu.org
  2022-04-13  6:46 ` [Bug fortran/105242] " burnus at gcc dot gnu.org
  2022-04-13 11:25 ` jakub at gcc dot gnu.org
@ 2022-04-13 14:58 ` burnus at gcc dot gnu.org
  2022-04-13 15:30 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-04-13 14:58 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-04-13
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |burnus at gcc dot gnu.org

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> Why do you say accepts invalid for C/C++?

Because I messed up initially due to doing do much in parallel, found the
issue, but forget to delete that line before hitting 'save'.

I have patch – the problem is that the check does exist, but only takes care of
a small subset of directives.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/105242] [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147
  2022-04-12 16:43 [Bug fortran/105242] New: [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147 burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-04-13 14:58 ` burnus at gcc dot gnu.org
@ 2022-04-13 15:30 ` burnus at gcc dot gnu.org
  2022-04-13 16:41 ` cvs-commit at gcc dot gnu.org
  2022-04-13 16:41 ` burnus at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-04-13 15:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Submitted patch:
  https://gcc.gnu.org/pipermail/gcc-patches/2022-April/593194.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/105242] [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147
  2022-04-12 16:43 [Bug fortran/105242] New: [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147 burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-04-13 15:30 ` burnus at gcc dot gnu.org
@ 2022-04-13 16:41 ` cvs-commit at gcc dot gnu.org
  2022-04-13 16:41 ` burnus at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-13 16:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:469fad0161afeb9369010ad498198297993ca592

commit r12-8145-g469fad0161afeb9369010ad498198297993ca592
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Wed Apr 13 18:40:52 2022 +0200

    OpenMP/Fortran: Fix EXIT in loop diagnostic [PR105242]

    gcc/fortran/ChangeLog:

            PR fortran/105242
            * match.cc (match_exit_cycle): Handle missing OMP LOOP, DO and SIMD
            directives in the EXIT/CYCLE diagnostic.

    gcc/testsuite/ChangeLog:

            PR fortran/105242
            * gfortran.dg/gomp/loop-exit.f90: New test.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/105242] [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147
  2022-04-12 16:43 [Bug fortran/105242] New: [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147 burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-04-13 16:41 ` cvs-commit at gcc dot gnu.org
@ 2022-04-13 16:41 ` burnus at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-04-13 16:41 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> ---
FIXED on MAINLINE (= GCC 12)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-04-13 16:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 16:43 [Bug fortran/105242] New: [OpenMP] ICE with EXIT in collapsed loop: in gfc_trans_exit, at fortran/trans-stmt.cc:6147 burnus at gcc dot gnu.org
2022-04-13  6:46 ` [Bug fortran/105242] " burnus at gcc dot gnu.org
2022-04-13 11:25 ` jakub at gcc dot gnu.org
2022-04-13 14:58 ` burnus at gcc dot gnu.org
2022-04-13 15:30 ` burnus at gcc dot gnu.org
2022-04-13 16:41 ` cvs-commit at gcc dot gnu.org
2022-04-13 16:41 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).