https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109699
Bug ID: 109699 Summary: With OpenACC reallocating a fortran pointer on a user type with allocatable fails. Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: patrick.be...@univ-grenoble-alpes.fr Target Milestone: --- Created attachment 54970 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54970&action=edit Test case to show the problem With OpenACC reallocating a fortran pointer on a user type with allocatable fails. Type is: type r2tab double precision, dimension(:,:), allocatable :: val integer :: dim1 integer :: dim2 end type r2tab Variable in main to offload is: type(r2tab), pointer :: tab=>null() Gfortran 14.0 from master branch commit 8d2793ef6b15dbdd347c854f663eb145af5ee593 Author: Marek Polacek <pola...@redhat.com> Date: Thu Mar 9 18:43:34 2023 -0500 But also 12.2.1 20230302 [OG12] Short test case attached to reproduce. Compilation with gfortran 14 using: gfortran -cpp -g -fopenacc testcase_begou.f90 -o testcase_begou Execution output (wrong) with gfortran from master: $ ./testcase_begou ================================================= ======================= 1 ======================= ================================================= =====>> ajoute: allocating on host and on device =====>> ajoute OK ====> usage in main: set array to 1 on device ====> usage in main OK Before update from the device, on host (should be 0): 0.000000 After update from device, on host shoud be 100: 100.000000 =====>> destroy datas on device and on host =====>> destroy OK ================================================= ======================= 2 ======================= ================================================= =====>> ajoute: allocating on host and on device =====>> ajoute OK ====> usage in main: set array to 2 on device libgomp: cuStreamSynchronize error: an illegal memory access was encountered With gfortran 12.2.1 the error message is a little bit more detailed (only error message below, standard output is the same): libgomp: cuStreamSynchronize error: an illegal memory access was encountered libgomp: cuModuleGetFunction (__do_global_dtors__entry) error: an illegal memory access was encountered libgomp: device finalization failed Hosts used with GNU compilers: - AMD Epyc 7302 + Nvidia A100, CentOS8 - i7-12700H + Nvidia T600, Alma Linux8 Code works on : - AMD Epyc 7302 + Nvidia A100, CentOS8 with Nvfortran 22.5-0: nvfortran -acc=gpu,noautopar -gpu=cc80 -Mpreprocess testcase_begou.f90 -o testcase_begou - i7-12700H + Nvidia T600, Alma Linux8 with Nvfortran 23.3-0: - nvfortran -acc=gpu,noautopar -gpu=cc75 -Mpreprocess testcase_begou.f90 -o testcase_begou - AMD EPYC 7542 + AMD MI 100 with Cray ftn 14.0.2: - ftn -g -hacc -hnoomp -eF testcase_begou.f90 -o testcase_begou Correct output is: ================================================= ======================= 1 ======================= ================================================= =====>> ajoute: allocating on host and on device =====>> ajoute OK ====> usage in main: set array to 1 on device ====> usage in main OK Before update from the device, on host (should be 0): 0.000000 After update from device, on host shoud be 100: 100.000000 =====>> destroy datas on device and on host =====>> destroy OK ================================================= ======================= 2 ======================= ================================================= =====>> ajoute: allocating on host and on device =====>> ajoute OK ====> usage in main: set array to 2 on device ====> usage in main OK Before update from the device, on host (should be 0): 0.000000 After update from device, on host shoud be 800: 800.000000 =====>> destroy datas on device and on host =====>> destroy OK Thanks Patrick