https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123255
Bug ID: 123255
Summary: OpenACC: copyin of allocatable array component
computes wrong size
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: albert at tugraz dot at
Target Milestone: ---
current trunk; repo base upstream/master at
769041822723208bf85a91ac409b9b0bdae3fff0 (2025-12-22)
COLLECT_GCC=/opt/gcc16/bin/gfortran
COLLECT_LTO_WRAPPER=/opt/gcc16/libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-pc-linux-gnu
Thread model: posix
gcc version 16.0.0 20251222 (experimental) (GCC)
When mapping an allocatable array component of a derived type to the device
using !$acc enter data copyin(obj%array), libgomp computes the wrong size for
the copy operation. It uses the array descriptor size (64 bytes) instead of the
actual allocated data size, causing "invalid size" error.
Reproducer:
program mre
use, intrinsic :: iso_fortran_env, only: dp => real64
implicit none
type :: container_t
integer :: n
real(dp), allocatable :: data(:)
end type container_t
type(container_t) :: c
integer :: i
c%n = 1000
allocate(c%data(c%n))
c%data = [(real(i, dp), i = 1, c%n)]
print *, "Array size (bytes):", size(c%data) * 8
!$acc enter data copyin(c%data)
print *, "PASS"
!$acc exit data delete(c%data)
end program mre
Build and run:
gfortran -O2 -fopenacc -foffload=nvptx-none mre.f90 -o mre
ACC_DEVICE_TYPE=nvidia ./mre
Output:
Array size (bytes): 8000
libgomp: invalid size
libgomp: Copying of host object [0x4040c8..0x404108) to dev object
[0x7fd8ab600000..0x7fd8ab600040) failed
The host object range 0x4040c8..0x404108 is only 64 bytes (0x40), which is
the
array descriptor size, not the actual data (8000 bytes for 1000 doubles).