https://bugs.kde.org/show_bug.cgi?id=387766

--- Comment #6 from Julian Seward <jsew...@acm.org> ---
Verified .. gcc version 8.0.0 20171210 runs clean on x86_64 linux when
configured with --enable-valgrind-annotations, the trunk, and the
https://bugs.kde.org/show_bug.cgi?id=387664 patch, which will land soon.
I didn't try without the patch.

I should note in passing, that I previously tried the 20171203 snapshot
without --enable-valgrind-annotations, since I was not aware of it.
I got a lot of complaints, all originating from sparseset_bit_p() in
gcc/sparseset.h, because this deliberately does a comparison on
undefined values.  I fixed this using the patch below.

I mention this because I am concerned that --enable-valgrind-annotations
might "fix" the problem by zero-initialising various allocations that create
memory used in sparseset_bit_p().  IMO that is the wrong solution, because
it will "hide" any legitimate uninitialised values that would otherwise have
been read from such allocations -- and so you reduce Memcheck's ability
to detect errors in gcc.  That said, this is only speculation -- I haven't
actually checked what --enable-valgrind-annotations does.

My fix follows.  Clearly you'd actually want to ifdef the macro call so
that this actually builds on targets that don't have <valgrind/memcheck.h>.


--- gcc-8-20171203/gcc/sparseset.h~     2017-01-01 13:07:43.000000000 +0100
+++ gcc-8-20171203/gcc/sparseset.h      2017-12-06 10:21:00.447480896 +0100
@@ -130,24 +130,27 @@
 static inline SPARSESET_ELT_TYPE
 sparseset_size (sparseset s)
 {
   return s->size;
 }

 /* Return true if e is a member of the set S, otherwise return false.  */

+#include <valgrind/memcheck.h>
+
 static inline bool
 sparseset_bit_p (sparseset s, SPARSESET_ELT_TYPE e)
 {
   SPARSESET_ELT_TYPE idx;

   gcc_checking_assert (e < s->size);

   idx = s->sparse[e];
+  VALGRIND_MAKE_MEM_DEFINED(&idx, sizeof(idx));

   return idx < s->members && s->dense[idx] == e;
 }

 /* Low level insertion routine not meant for use outside of sparseset.[ch].
    Assumes E is valid and not already a member of the set S.  */

 static inline void

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to