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

            Bug ID: 127866
           Summary: [OpenMP] Mapping derived type allocatable component
                    with additional clause triggers ICE
           Product: gcc
           Version: 16.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: utheriwagura at proton dot me
  Target Milestone: ---

I'm current getting an internal compiler error when I try and map or allocate
an allocatable component of a derived type in an OpenMP "target enter data
map(to: .." or "map(alloc:.." directive that ends in an additional clause such
as "if (condition)". Here is a short reproducer: 

module m
  implicit none
  type :: inner_t
    real, allocatable :: a(:)   ! any allocatable component (array, scalar,
class) triggers it
  end type inner_t
  type :: outer_t
    type(inner_t), pointer :: p => null()
  end type outer_t
contains
  subroutine s(x, l)
    type(outer_t), intent(inout) :: x
    logical, intent(in) :: l
    !$omp target enter data map(to: x%p) if (l)
  end subroutine s
end module m

Note that "omp target enter map(alloc:)" also gives the ICE. Alloc also seems
to give the ICE without the pointer to the derived type, but a "map(to: )"
directive is okay in the following reproducer: 

module m2
  implicit none
  type :: inner_t
    real, allocatable :: a(:)
  end type inner_t
contains
  subroutine s(y, l)
    type(inner_t), intent(inout) :: y
    logical, intent(in) :: l
    !$omp target enter data map(alloc: y) if (l)
  end subroutine s
end module m2


All reproducers were compiled with the following command:
gfortran -fopenmp -c ice.f90 

and the following version of gcc:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/16/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,cobol,algol68,lto
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugzilla.redhat.com/ --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu
--enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-16.2.1-build/gcc-16.2.1-20260819/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none,amdgcn-amdhsa --enable-offload-defaulted
--without-cuda-driver --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-tls=gnu2 --with-arch_32=i686
--build=x86_64-redhat-linux --with-build-config=bootstrap-lto
--enable-link-serialization=1 --disable-libssp
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.2.1 20260819 (Red Hat 16.2.1-2) (GCC)

Reply via email to