https://gcc.gnu.org/g:655a8a024dd49ddf73e745f3c7486596d68ae3e8

commit r15-6869-g655a8a024dd49ddf73e745f3c7486596d68ae3e8
Author: Paul-Antoine Arras <par...@baylibre.com>
Date:   Mon Jan 13 12:57:15 2025 +0100

    Add missing target directive in OpenMP dispatch Fortran runtime test
    
    Without the target directive, the test would run on the host but still try 
to
    use device pointers, which causes a segfault.
    
    libgomp/ChangeLog:
    
            * testsuite/libgomp.fortran/dispatch-1.f90: Add missing target
            directive.

Diff:
---
 libgomp/testsuite/libgomp.fortran/dispatch-1.f90 | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/libgomp/testsuite/libgomp.fortran/dispatch-1.f90 
b/libgomp/testsuite/libgomp.fortran/dispatch-1.f90
index 7b2f03f9d687..f56477e49722 100644
--- a/libgomp/testsuite/libgomp.fortran/dispatch-1.f90
+++ b/libgomp/testsuite/libgomp.fortran/dispatch-1.f90
@@ -48,16 +48,21 @@ module procedures
     integer :: res, n, i
     type(c_ptr) :: d_bv
     type(c_ptr) :: d_av
-    real(8), pointer :: fp_bv(:), fp_av(:)  ! Fortran pointers for array access
 
-    ! Associate C pointers with Fortran pointers
-    call c_f_pointer(d_bv, fp_bv, [n])
-    call c_f_pointer(d_av, fp_av, [n])
+    !$omp target is_device_ptr(d_bv, d_av)
+    block
+      real(8), pointer :: fp_bv(:), fp_av(:)  ! Fortran pointers for array 
access
+
+      ! Associate C pointers with Fortran pointers
+      call c_f_pointer(d_bv, fp_bv, [n])
+      call c_f_pointer(d_av, fp_av, [n])
+
+      ! Perform operations on target
+      do i = 1, n
+        fp_bv(i) = fp_av(i) * i
+      end do
+    end block
 
-    ! Perform operations on target
-    do i = 1, n
-      fp_bv(i) = fp_av(i) * i
-    end do
     res = -2
   end function bar

Reply via email to