Hi,

in PR 61186 valgrind reports use of uninitialized value.  The reason
is that walk_polymorphic_call_targets uses cache_token before it
checks return value of possible_polymorphic_call_targets which however
does not produce a cache token if it fails early.  This is not the
only place where we make this mistake so I decided to store NULL to
cache_token in these cases instead.  I understand this slightly
controversial as it means that the callers making this error will now
end up with a NULL pointer in their pointer_sets (which they use in
order not to process the same results multiple times).  It just seemed
quite a lot easier and also avoids making the same mistake elsewhere
in future.

Bootstrapped and tested on x86_64-linux, I have of course also
verified it fixes the bug.  OK for trunk?  And perhaps also the 4.9
branch?

Thanks,

Martin


2014-06-11  Martin Jambor  <mjam...@suse.cz>

        PR ipa/61186
        * ipa-devirt.c (possible_polymorphic_call_targets): Store NULL to
        cache_token if returning early.

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index d733461..a90d1dc 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1603,6 +1603,8 @@ possible_polymorphic_call_targets (tree otr_type,
     {
       if (completep)
        *completep = false;
+      if (cache_token)
+       *cache_token = NULL;
       if (nonconstruction_targetsp)
        *nonconstruction_targetsp = 0;
       return nodes;
@@ -1613,6 +1615,8 @@ possible_polymorphic_call_targets (tree otr_type,
     {
       if (completep)
        *completep = true;
+      if (cache_token)
+       *cache_token = NULL;
       if (nonconstruction_targetsp)
        *nonconstruction_targetsp = 0;
       return nodes;
@@ -1626,6 +1630,8 @@ possible_polymorphic_call_targets (tree otr_type,
     {
       if (completep)
        *completep = false;
+      if (cache_token)
+       *cache_token = NULL;
       if (nonconstruction_targetsp)
        *nonconstruction_targetsp = 0;
       return nodes;

Reply via email to