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

            Bug ID: 108857
           Summary: [OpenMP] Use of uninitialized var when mapping
                    unallocated deferred-length character string
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

There are several issues with deferred-length strings (with and without
openmp).
Here's another one:


The following code uses uninitialized memory (hidden string-length var).

EXPECTED:

   size = var == NULL ? 0 : .var * kind;

Actually done: unconditionally using '.var * kind', i.e.

  integer(kind=8) .a4str2;
  character(kind=4)[1:.a4str2] * a4str2;
...
      a4str2 = 0B;
...
      .a4str2.1_1 = (sizetype) .a4str2;
      D.4271 = .a4str2.1_1 * 4;
...
#pragma omp target ... map(from:(*a4str2.2_2) [len: D.4271]) ...


Testcase:
!------------------------------------------------------

character(len=:,kind=4), allocatable :: a4str2

!$omp target map(from: a4str2)
  if (allocated(a4str2)) error stop
!$omp end target
end

Reply via email to