On 9/15/20 7:03 PM, Jakub Jelinek wrote:
On Tue, Sep 15, 2020 at 12:48:59AM +0200, Tobias Burnus wrote:
+ bool has_nullptr;
+ size_t j;
+ for (j = 0; j < n->tgt->list_count; j++)
+ if (n->tgt->list[j].key == n)
+ {
+ has_nullptr = n->tgt->list[j].has_null_ptr_assoc;
+ break;
+ }
+ if (n->tgt->list_count == 0)
+ has_nullptr = true;
+ else
+ assert (j < n->tgt->list_count);
David Edelsohn just reported this (rightly so) results in -Wuninitialized
warnings, I think you meant bool has_nullptr = false;
in the definition (in both places that it is defined at).
No, I meant that it should be always set.
I think the uninitialized warning is a false positive:
list_count and j are unsigned. For list_count == 0 (and, hence, j = 0),
the value is set (special case). Otherwise, if j < list_count, has_nullptr
has been set via the 'for' loop. If it is not set in the loop, j == list_count
and that's (plus j > list_count) caught by the assert.
I admit that with the assert being disabled (NDEBUG is set), that's not
visible to the compiler but otherwise, it should be able to find out.
Tobias
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander
Walter
commit 1b9bdd52037061d7a5bd77d177b060c93c528a5d
Author: Tobias Burnus <tob...@codesourcery.com>
Date: Tue Sep 15 21:28:40 2020 +0200
libgomp/target.c: Silence -Wuninitialized warning
libgomp/ChangeLog:
PR fortran/96668
* target.c (gomp_map_vars_internal): Initialize has_nullptr.
diff --git a/libgomp/target.c b/libgomp/target.c
index 69cdd9f14a9..ab7ac9ba8d2 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -854,7 +854,7 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
int always_to_cnt = 0;
if ((kind & typemask) == GOMP_MAP_TO_PSET)
{
- bool has_nullptr;
+ bool has_nullptr = false;
size_t j;
for (j = 0; j < n->tgt->list_count; j++)
if (n->tgt->list[j].key == n)
@@ -1017,7 +1017,7 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
== GOMP_MAP_TO_PSET)
{
splay_tree_key k = tgt->list[i].key;
- bool has_nullptr;
+ bool has_nullptr = false;
size_t j;
for (j = 0; j < k->tgt->list_count; j++)
if (k->tgt->list[j].key == k)