https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84405

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, seems it is that hash-table.h change that really doesn't work in GCC
r132088, not just 4.2.*, but any (tried even 3.2).

The implicitly defined default constructor for A (hash_map<...>::hash_entry in
gcc) doesn't initialize the POD t field (which is correct I assume, current
trunk doesn't do that either), but the value initialization before r132088 only
constructs the non-POD u field of A and doesn't initialize t at all (in GCC
that is the m_key, in the stuck case with type edge_def *).

extern "C" void abort ();
template<typename T, typename U>
struct A { T t; U u; };
struct B { B (); ~B (); int b; };
B::B () : b (9) {}
B::~B () {}
template <typename T>
void foo (T *p) { *p = T (); }

int
main ()
{
  int a;
  A<int *, B> h;
  h.t = &a;
  foo (&h);
  if (h.t)
    abort ();
}

So, either we need to conditionally revert (for say
#if GCC_VERSION != 0 && GCC_VERSION < 4003 && !defined(__clang__)
) the hash-table.h change and use memset.h for old GCCs, or we need some
template hackery to determine if value_type is hash_map<something>::hash_entry
from hash-map.h and instead of using *entries = value_type (); do
entries->m_key = value_type::compare_type ();
entries->m_value = something ();

Ugh.

Reply via email to