public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/97084] New: Openmp + Allocatable String Crashes
@ 2020-09-17 10:28 wddawson at ucdavis dot edu
  2020-10-06 13:16 ` [Bug fortran/97084] " dominiq at lps dot ens.fr
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: wddawson at ucdavis dot edu @ 2020-09-17 10:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97084
           Summary: Openmp + Allocatable String Crashes
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wddawson at ucdavis dot edu
  Target Milestone: ---

Minimal example
```
program test
  implicit none
  integer :: ii
  integer, parameter :: N = 80
  character(len=:), allocatable :: temp_string

  allocate(character(len=N) :: temp_string)

  !$omp parallel default(shared)
  !$omp do
  do ii = 1, N
     temp_string(ii:ii) = "#"
  end do
  !$omp end do
  !$omp end parallel
end program
```

When I compile with `gfortran main.f90 -fopenmp -o test ` I get the following
error:
```
during GIMPLE pass: omplower
main.f90:9:0:

    9 |   !$omp parallel default(shared)
      | 
internal compiler error: in gimplify_expr, at gimplify.c:13885
libbacktrace could not find executable to open
```
It fails with the following compilers:
```
GNU Fortran (Homebrew GCC 10.2.0) 10.2.0
```
```
GNU Fortran (Homebrew GCC 9.3.0) 9.3.0
```
But works with:
```
GNU Fortran (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
```

This is possibly related to 89621?

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

* [Bug fortran/97084] Openmp + Allocatable String Crashes
  2020-09-17 10:28 [Bug fortran/97084] New: Openmp + Allocatable String Crashes wddawson at ucdavis dot edu
@ 2020-10-06 13:16 ` dominiq at lps dot ens.fr
  2020-10-07  7:16 ` burnus at gcc dot gnu.org
  2020-10-07  7:42 ` burnus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-10-06 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-10-06
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed from at least GG7 up to GCC10. With GCC11 the ICE is

during GIMPLE pass: omplower
pr97084.f90:9:0:

    9 |   !$omp parallel default(shared)
      | 
internal compiler error: in gfc_add_modify_loc, at fortran/trans.c:163

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

* [Bug fortran/97084] Openmp + Allocatable String Crashes
  2020-09-17 10:28 [Bug fortran/97084] New: Openmp + Allocatable String Crashes wddawson at ucdavis dot edu
  2020-10-06 13:16 ` [Bug fortran/97084] " dominiq at lps dot ens.fr
@ 2020-10-07  7:16 ` burnus at gcc dot gnu.org
  2020-10-07  7:42 ` burnus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-10-07  7:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Trying with:
  character(len=:), allocatable :: temp_string
  character(len=N) :: temp_string2
(using one or the other)

Both get set to 'shared' initially; in omp-low.c' scan_sharing_clauses:
        case OMP_CLAUSE_SHARED:
...
          by_ref = use_pointer_for_field (decl, NULL);

As "temp_string2" is a string/array, by_ref is true as:
  if (AGGREGATE_TYPE_P (TREE_TYPE (decl))
      || TYPE_ATOMIC (TREE_TYPE (decl)))
    return true;

By contrast, temp_string is a pointer to a string/array, has 'by_ref = false'
and, hence,
          /* We don't need to copy const scalar vars back.  */
          OMP_CLAUSE_SET_CODE (c, OMP_CLAUSE_FIRSTPRIVATE);

→ This statement is definitely wrong as it is not a scalar (in the OpenMP
sense) and it is also not 'const' and it should be addressable.

The question is why not any of the many items in the if condition following
line 1143's "by_ref =" is true.


Back to the ICE: Then, via lower_rec_input_clauses, gfc_omp_clause_copy_ctor is
called and we end up at:
  gfc_start_block (&block);
  gfc_init_block (&cond_block);
  gfc_add_modify (&cond_block, dest, src));

"lhs = rhs" is:
  temp_string = .omp_data_s.1.temp_string

where both lhs and rhs are pointers to an array; in the dump both types look
identical but are different pointer/array types. Thus, the following assert
fails in gfc_add_modify_loc:

  gcc_checking_assert (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2)
                       || AGGREGATE_TYPE_P (TREE_TYPE (lhs)));

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

* [Bug fortran/97084] Openmp + Allocatable String Crashes
  2020-09-17 10:28 [Bug fortran/97084] New: Openmp + Allocatable String Crashes wddawson at ucdavis dot edu
  2020-10-06 13:16 ` [Bug fortran/97084] " dominiq at lps dot ens.fr
  2020-10-07  7:16 ` burnus at gcc dot gnu.org
@ 2020-10-07  7:42 ` burnus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-10-07  7:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
If one assumes that the pointer can be privatized (as the pointer target is
updated) and adds in  gfc_omp_clause_copy_ctor  a simple
   return build2_v (MODIFY_EXPR, dest, src);
it compiles and runs but the first 16 characters are overridden by:
7× \0, \108, \0, 3× <random>, 2× \0. The remaining 17 to 80 have '#' as
expected.

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 10:28 [Bug fortran/97084] New: Openmp + Allocatable String Crashes wddawson at ucdavis dot edu
2020-10-06 13:16 ` [Bug fortran/97084] " dominiq at lps dot ens.fr
2020-10-07  7:16 ` burnus at gcc dot gnu.org
2020-10-07  7:42 ` 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).