<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/113106>113106</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] assumed-shape array of character type with allocatable attribute in task private construct in parallel private construct does not execute correctly
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:openmp
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 20.0.0(77f8297c6fdaa62121ddb108043dcaad5c45c7ad)/AArch64
```

`assumed-shape array` of `character` type with `allocatable` attribute in `task private` construct in `parallel private` construct does not execute correctly. 
The above program is `dw2_007_tsk_231.f90`.

Correct execution results are obtained in the following cases.
- The length of the `character type` is a constant instead of `*`  
  The above program is `dw2_007_tsk_232.f90`.
- Remove `task private` construct
- Do not specify compilation options (`-fopenmp`)


The following are the test program, Flang-new, Gfortran and ifx compilation/execution result.

dw2_007_tsk_231.f90:
```fortran
subroutine sub01(arg01)
  character(*),allocatable :: arg01(:)
 allocate(arg01(1))
  arg01(1) = "abcde12345"
  write(6,*) "1:len(arg01) = ", len(arg01)
!  if ( 10 .ne. len(arg01)) print *,'ng1'
!$omp parallel private(arg01)
!$omp task private(arg01)
 write(6,*) "2:len(arg01) = ", len(arg01)
!  if ( 10 .ne. len(arg01)) print *,'ng2',len(arg01)
!$omp end task
!$omp end parallel
end subroutine sub01

program main
  interface
     subroutine sub01(arg01)
       character(*),allocatable :: arg01(:)
     end subroutine sub01
  end interface

  character(10),allocatable :: cha01(:)
  call sub01(cha01)
end program main
```

```
$ export OMP_NUM_THREADS=2; flang-new -fopenmp dw2_007_tsk_231.f90; ./a.out
 1:len(arg01) =  10
 2:len(arg01) =  0
 2:len(arg01) = 0
$
```

```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp dw2_007_tsk_231.f90; ./a.out
 1:len(arg01) =           10
 2:len(arg01) =           10
 2:len(arg01) =           10
$
```

```
$ export OMP_NUM_THREADS=2; ifx -qopenmp dw2_007_tsk_231.f90; ./a.out
 1:len(arg01) =           10
 2:len(arg01) =           10
 2:len(arg01) = 10
$
```

dw2_007_tsk_232.f90:
```fortran
subroutine sub01(arg01)
  character(10),allocatable :: arg01(:)
 allocate(arg01(1))
  arg01(1) = "abcde12345"
  write(6,*) "1:len(arg01) = ", len(arg01)
!  if ( 10 .ne. len(arg01)) print *,'ng1'
!$omp parallel private(arg01)
!$omp task private(arg01)
 write(6,*) "2:len(arg01) = ", len(arg01)
!  if ( 10 .ne. len(arg01)) print *,'ng2',len(arg01)
!$omp end task
!$omp end parallel
end subroutine sub01

program main
  interface
     subroutine sub01(arg01)
       character(10),allocatable :: arg01(:)
     end subroutine sub01
  end interface

  character(10),allocatable :: cha01(:)
  call sub01(cha01)
end program main
```

```
$ export OMP_NUM_THREADS=2; flang-new -fopenmp dw2_007_tsk_232.f90; ./a.out
 1:len(arg01) =  10
 2:len(arg01) =  10
 2:len(arg01) = 10
$
```

```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp dw2_007_tsk_232.f90; ./a.out
 1:len(arg01) =           10
 2:len(arg01) =           10
 2:len(arg01) =           10
$
```

```
$ export OMP_NUM_THREADS=2; ifx -qopenmp dw2_007_tsk_232.f90; ./a.out
 1:len(arg01) =           10
 2:len(arg01) =           10
 2:len(arg01) =           10
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWEuP2zYQ_jX0ZWCBGj0sHXzwruv2kiZI014XFEVZTGhSJand7L8vKEtre9fOAzH6wgoGBHNGH-f7OMMByZyTWy3EkmQ3JFvPWO9bY5em1WbefJxVpn5ckpyOP7omdPWHsE4aDaaBRjG9nWvxACRZAdKIRpRgsVg0BZYLnjc1YznGGNd1FdOCpknNGasznmZ8wWqCJcHNamV5m6d78GdzPQ0y5_qdqOeuZZ0AZi17JDkNMZC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