From 7ea60a544353fa9ff0760e11db53332195eebad4 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tschwinge@baylibre.com>
Date: Wed, 6 Mar 2024 23:18:08 +0100
Subject: [PATCH] Fix 'char' initialization, copy, check in
'libgomp.oacc-fortran/acc-memcpy.f90'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Our dear friend '-Wuninitialized' reported:
[...]/libgomp.oacc-fortran/acc-memcpy.f90:18:27:
18 | char(j) = int (j, int8)
| ^
Warning: ‘j’ may be used uninitialized [-Wmaybe-uninitialized]
[...]/libgomp.oacc-fortran/acc-memcpy.f90:14:20:
14 | integer(int8) :: j
| ^
note: ‘j’ was declared here
..., but actually there were other issues.
libgomp/
* testsuite/libgomp.oacc-fortran/acc-memcpy.f90: Fix 'char'
initialization, copy, check.
---
libgomp/testsuite/libgomp.oacc-fortran/acc-memcpy.f90 | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
@@ -11,15 +11,14 @@ program main
integer(int8), allocatable :: char(:)
type(c_ptr) :: dptr
integer(c_intptr_t) :: i
- integer(int8) :: j
allocate(char(-128:127))
do i = -128, 127
- char(j) = int (j, int8)
+ char(i) = int (i, int8)
end do
dptr = acc_malloc (256_c_size_t)
- call acc_memcpy_to_device (dptr, char, 255_c_size_t)
+ call acc_memcpy_to_device (dptr, char, 256_c_size_t)
do i = 0, 255
if (acc_is_present (transfer (transfer(char, i) + i, dptr), 1)) &
@@ -31,8 +30,7 @@ program main
call acc_memcpy_from_device (char, dptr, 256_c_size_t)
do i = -128, 127
- char(i) = int (j, int8)
- if (char(i) /= j) &
+ if (char(i) /= i) &
stop 2
end do
--
2.34.1