This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] warn on mem calls modifying objects of non-trivial types (PR 80560)


> 
> The warning in the original code could have been suppressed (by
> casting the pointer to char*), but it was valid so I opted not
> to.  I'd expect it to be possible to work around the bug but
> I don't have easy access to GCC 4.2 to reproduce it or verify
> the fix.
> 
> FWIW, after looking at the function again, I wondered if zeroing
> out the elements (either way) was the right thing to do and if
> they shouldn't be cleared by calling Descriptor::mark_empty()
> instead, like in alloc_entries(), but making that change broke
> a bunch of ipa/ipa-pta-*.c tests.  It's not really clear to me
> what this code is supposed to do.

Well, it is a standard hash table.  The problem I hit was
lookup_with_hash walking infinitly around the hash table because
all elements seemed used.
is_empty is defined as:
template <typename Type>
inline bool
pointer_hash <Type>::is_empty (Type *e)
{
  return e == NULL;
}

and mark_empty as
template <typename Type>                                                        
inline void
pointer_hash <Type>::mark_empty (Type *&e)
{
  e = NULL;
}

I guess they are supposed to be definable to other implementations
but then the former memset code would break.
> Martin
> 
> PS Does this help at all?
> 
> @@ -804,8 +804,8 @@ hash_table<Descriptor, Allocator>::empty_slow ()
>      }
>    else
>      {
> -      for ( ; size; ++entries, --size)
> -       *entries = value_type ();
> +      for (size_t i = 0; i != size; ++i)
> +       entries[i] = value_type ();

I can give it a try tomorrow.  Still wonder what goes wrong with ctors with 4.2 (and 4.3 as well apparently)

Honza
>      }
>    m_n_deleted = 0;
>    m_n_elements = 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]