public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104131] New: ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810
@ 2022-01-19 18:53 gscfq@t-online.de
  2022-01-20 10:19 ` [Bug fortran/104131] " marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2022-01-19 18:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104131
           Summary: ICE in gfc_conv_array_ref, at
                    fortran/trans-array.c:3810
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Changed between 20210110 and 20210117 :
(array instead of scalar x)


$ cat z1.f90
program p
   use iso_c_binding, only: c_intptr_t
   integer, parameter :: omp_event_handle_kind = c_intptr_t
   integer(omp_event_handle_kind) :: x(1)
   !$omp task detach(x)
   !$omp end task
end


$ gfortran-12-20220116 -c z1.f90 -fopenmp
z1.f90:5:23:

    5 |    !$omp task detach(x)
      |                       1
internal compiler error: in gfc_conv_array_ref, at fortran/trans-array.c:3810
0x7ab735 gfc_conv_array_ref(gfc_se*, gfc_array_ref*, gfc_expr*, locus*)
        ../../gcc/fortran/trans-array.c:3809
0x7d9dce gfc_conv_variable
        ../../gcc/fortran/trans-expr.c:3097
0x7d61aa gfc_conv_expr(gfc_se*, gfc_expr*)
        ../../gcc/fortran/trans-expr.c:9406
0x811d35 gfc_trans_omp_clauses
        ../../gcc/fortran/trans-openmp.c:4080
0x8182c9 gfc_trans_omp_task
        ../../gcc/fortran/trans-openmp.c:6618
0x8182c9 gfc_trans_omp_directive(gfc_code*)
        ../../gcc/fortran/trans-openmp.c:7457
0x7a5317 trans_code
        ../../gcc/fortran/trans.c:2210
0x7ce56e gfc_generate_function_code(gfc_namespace*)
        ../../gcc/fortran/trans-decl.c:7651
0x7513ce translate_all_program_units
        ../../gcc/fortran/parse.c:6651
0x7513ce gfc_parse_file()
        ../../gcc/fortran/parse.c:6938
0x79e33f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.c:216

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

* [Bug fortran/104131] ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810
  2022-01-19 18:53 [Bug fortran/104131] New: ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810 gscfq@t-online.de
@ 2022-01-20 10:19 ` marxin at gcc dot gnu.org
  2022-01-26 17:25 ` gscfq@t-online.de
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-20 10:19 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |kcy at codesourcery dot com,
                   |                            |marxin at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-01-20

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r11-6752-ga6d22fb21c6f1ad7.

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

* [Bug fortran/104131] ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810
  2022-01-19 18:53 [Bug fortran/104131] New: ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810 gscfq@t-online.de
  2022-01-20 10:19 ` [Bug fortran/104131] " marxin at gcc dot gnu.org
@ 2022-01-26 17:25 ` gscfq@t-online.de
  2022-03-03 10:28 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2022-01-26 17:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from G. Steinmetz <gscfq@t-online.de> ---
And with a coarray :


$ cat zz1.f90
program p
   use iso_c_binding, only: c_intptr_t
   integer, parameter :: omp_event_handle_kind = c_intptr_t
   integer (kind=omp_event_handle_kind) :: x[*]
   !$omp task detach (x)
   !$omp end task
end


$ cat zz2.f90
program p
   use iso_c_binding, only: c_intptr_t
   integer, parameter :: omp_event_handle_kind = c_intptr_t
   integer (kind=omp_event_handle_kind) :: x[*]
   !$omp parallel master default (none)
      !$omp task detach (x)
      !$omp end task
   !$omp end parallel master
end


$ gfortran-12-20220123 -c zz1.f90 -fopenmp -fcoarray=single
zz1.f90:5:24:

    5 |    !$omp task detach (x)
      |                        ^
internal compiler error: Segmentation fault
0xcc430f crash_signal
        ../../gcc/toplev.cc:322
0xa229da omp_add_variable
        ../../gcc/gimplify.cc:7200
0xa32f20 gimplify_scan_omp_clauses
        ../../gcc/gimplify.cc:10305
0xa267ce gimplify_omp_task
        ../../gcc/gimplify.cc:12122
0xa267ce gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.cc:15454
0xa29b18 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.cc:7035
0xa2a071 gimplify_bind_expr
        ../../gcc/gimplify.cc:1427
0xa2745a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.cc:15161
0xa29b18 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.cc:7035
0xa2ab9b gimplify_body(tree_node*, bool)
        ../../gcc/gimplify.cc:16206
0xa2afef gimplify_function_tree(tree_node*)
        ../../gcc/gimplify.cc:16360
0x8b26f7 cgraph_node::analyze()
        ../../gcc/cgraphunit.cc:675
0x8b50a7 analyze_functions
        ../../gcc/cgraphunit.cc:1240
0x8b5a6d symbol_table::finalize_compilation_unit()
        ../../gcc/cgraphunit.cc:2500

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

* [Bug fortran/104131] ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810
  2022-01-19 18:53 [Bug fortran/104131] New: ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810 gscfq@t-online.de
  2022-01-20 10:19 ` [Bug fortran/104131] " marxin at gcc dot gnu.org
  2022-01-26 17:25 ` gscfq@t-online.de
@ 2022-03-03 10:28 ` cvs-commit at gcc dot gnu.org
  2023-10-23 18:50 ` anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-03 10:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kwok Yeung <kcy@gcc.gnu.org>:

https://gcc.gnu.org/g:88c4d85e27e18bf991ab8728b73127a0385f2c27

commit r12-7464-g88c4d85e27e18bf991ab8728b73127a0385f2c27
Author: Kwok Cheung Yeung <kcy@codesourcery.com>
Date:   Thu Mar 3 10:23:26 2022 +0000

    openmp, fortran: Check that the type of an event handle in a detach clause
is suitable [PR104131]

    This rejects variables that are array types, array elements or derived type
    members when used as the event handle inside a detach clause (in accordance
    with the OpenMP specification).  This would previously lead to an ICE.

    2022-03-03  Kwok Cheung Yeung  <kcy@codesourcery.com>

    gcc/fortran/

            PR fortran/104131
            * openmp.cc (gfc_match_omp_detach): Move check for type of event
            handle to...
            (resolve_omp_clauses) ...here.  Also check that the event handle is
            not an array, or an array access or structure element access.

    gcc/testsuite/

            PR fortran/104131
            * gfortran.dg/gomp/pr104131.f90: New.
            * gfortran.dg/gomp/task-detach-1.f90: Update expected error
message.

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

* [Bug fortran/104131] ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810
  2022-01-19 18:53 [Bug fortran/104131] New: ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-03-03 10:28 ` cvs-commit at gcc dot gnu.org
@ 2023-10-23 18:50 ` anlauf at gcc dot gnu.org
  2023-10-23 19:15 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-23 18:50 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |12.1.0
      Known to fail|                            |11.4.0
             Status|NEW                         |WAITING

--- Comment #4 from anlauf at gcc dot gnu.org ---
This PR appears fixed.  Can it be closed?  Or is there anything left?

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

* [Bug fortran/104131] ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810
  2022-01-19 18:53 [Bug fortran/104131] New: ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2023-10-23 18:50 ` anlauf at gcc dot gnu.org
@ 2023-10-23 19:15 ` anlauf at gcc dot gnu.org
  2023-10-24 19:53 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-23 19:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from anlauf at gcc dot gnu.org ---
The coarray cases in comment#2 will be rejected with:

diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 1cc65d7fa49..08081dacde4 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -8967,6 +8967,9 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses
*omp_clauses,
       else if (omp_clauses->detach->symtree->n.sym->attr.dimension > 0)
        gfc_error ("The event handle at %L must not be an array element",
                   &omp_clauses->detach->where);
+      else if (omp_clauses->detach->symtree->n.sym->attr.codimension)
+       gfc_error ("The event handle at %L must not be a coarray",
+                  &omp_clauses->detach->where);
       else if (omp_clauses->detach->symtree->n.sym->ts.type == BT_DERIVED
               || omp_clauses->detach->symtree->n.sym->ts.type == BT_CLASS)
        gfc_error ("The event handle at %L must not be part of "


I assume that these are not allowed.

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

* [Bug fortran/104131] ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810
  2022-01-19 18:53 [Bug fortran/104131] New: ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2023-10-23 19:15 ` anlauf at gcc dot gnu.org
@ 2023-10-24 19:53 ` burnus at gcc dot gnu.org
  2023-10-24 20:26 ` anlauf at gcc dot gnu.org
  2023-10-25  7:07 ` burnus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2023-10-24 19:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> ---
!$omp task detach (x)
      !$omp end task

This seems to be valid. OpenMP mostly only rejects coindexed variables like:

"Fortran
A variable list item is one of the following:
• a variable that is not coindexed and that is not a substring"

"If more than one image is executing the program, any image control statement,
ERROR STOP statement, FAIL IMAGE statement, collective subroutine call or
access to a coindexed object that appears in an explicit OpenMP region will
result in unspecified behavior."

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

* [Bug fortran/104131] ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810
  2022-01-19 18:53 [Bug fortran/104131] New: ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2023-10-24 19:53 ` burnus at gcc dot gnu.org
@ 2023-10-24 20:26 ` anlauf at gcc dot gnu.org
  2023-10-25  7:07 ` burnus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-24 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #7 from anlauf at gcc dot gnu.org ---
(In reply to Tobias Burnus from comment #6)
> !$omp task detach (x)
>       !$omp end task
> 
> This seems to be valid. OpenMP mostly only rejects coindexed variables like:

Alright, I did not expect this, and no other compiler I have access to
accepts it.

Withdrawing my patch.

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

* [Bug fortran/104131] ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810
  2022-01-19 18:53 [Bug fortran/104131] New: ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2023-10-24 20:26 ` anlauf at gcc dot gnu.org
@ 2023-10-25  7:07 ` burnus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2023-10-25  7:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to anlauf from comment #7)
> (In reply to Tobias Burnus from comment #6)
> > !$omp task detach (x)
> >       !$omp end task
> > 
> > This seems to be valid. OpenMP mostly only rejects coindexed variables like:
> 
> Alright, I did not expect this, and no other compiler I have access to
> accepts it.

On the technical side, a coarray is just a normal variable that is also
remotely accessible; I think it is usually just 'malloc'ed but in principle the
coarray library could allocate it also in special memory.
There might be some issues when used inside target regions, i.e. on a device
with shared memory (page migrations etc.) but, otherwise, there is no real
reason to disallow it.

Of course, everything related to memory allocation or coindexed access will not
work (in general - at least some special cases will fail).

* * *

In terms of the OpenMP specification, there is a section "Normative
References";

* in OpenMP 5.0, it has: "Fortran 2008 ... their use may result in unspecified
behavior ... Coarrays"

* in OpenMP 5.1, there are no exceptions for 2008 and Fortran 2018 with a new
list of unspecified behavior was added.

Thus, coarrays were never explicitly rejected but in 5.0 their use might result
in unspecified behavior, i.e. an implementation could reject it.
Since 5.1, they can be used where deemed to be okay.

(Disclaimer: What might be okay for most implementation can be unimplementable
in another; additionally, some corner cases might have been overlooked which do
cause problems.)

* * *

My quotes in comment 6 were from OpenMP 5.2, the latest release. TR11 (pre-6.0)
is the latest spec, semi-solid but breaking changes are permitted until the
final 6.0 (to fix oversights).

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

end of thread, other threads:[~2023-10-25  7:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19 18:53 [Bug fortran/104131] New: ICE in gfc_conv_array_ref, at fortran/trans-array.c:3810 gscfq@t-online.de
2022-01-20 10:19 ` [Bug fortran/104131] " marxin at gcc dot gnu.org
2022-01-26 17:25 ` gscfq@t-online.de
2022-03-03 10:28 ` cvs-commit at gcc dot gnu.org
2023-10-23 18:50 ` anlauf at gcc dot gnu.org
2023-10-23 19:15 ` anlauf at gcc dot gnu.org
2023-10-24 19:53 ` burnus at gcc dot gnu.org
2023-10-24 20:26 ` anlauf at gcc dot gnu.org
2023-10-25  7:07 ` 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).