https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94635
Bug ID: 94635 Summary: [OpenMP][Offloading] mapping with alloc/delete followed by map(from/fromto fails Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: openmp, wrong-code Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- Based on an OpenMP test case from SOLLVE_VV, https://github.com/SOLLVE/sollve_vv/ Namely, based on tests/4.5/target_enter_exit_data/ test_target_enter_exit_data_allocate_array_alloc_delete.F90 The following test case works if one comments: !$omp target enter data map(alloc: my1DPtr(:)) !$omp target exit data map(delete: my1DPtr(:)) Then it prints the expected 42 … 10 … 10 … 20 … If one comments only the "map(delete:…)", it prints 42 … 10 … 0 … (should be: 10) 10 … (should be: 20) And with alloc/delete enabled, it prints: 42 … 10 … 20 20 … 31911936 17 31907872 17 31907952 (should be: 10) 10 … (should be: 20) In the 'target': when using "my1DArr = 99", the garbage values are replaced by 99, i.e. 20 20 … 99 99 … (twelf times 20 followed by eight times 99). The testsuite first tests whether alloc/delete works – which does; only re-using the alloc/delete space fails. Test case: ---------- implicit none INTEGER, PARAMETER :: N = 20 INTEGER, ALLOCATABLE, DIMENSION(:) :: my1DPtr INTEGER, DIMENSION(N) :: my1DArr allocate(my1DPtr(N)) !$omp target enter data map(alloc: my1DPtr(:)) !$omp target exit data map(delete: my1DPtr(:)) my1DPtr(:) = 10 my1DArr = 42 print *, my1DArr ! = 42, okay print *, my1DPtr ! = 10, okay !$omp target map(from: my1DArr) map(tofrom: my1DPtr(:)) my1DArr = my1DPtr my1DPtr(:) = 20 !$omp end target print *, my1DArr ! should be: 10 (not 0 or 20+garbage) print *, my1DPtr ! should be: 20 (and not 10) END