[hash] Work around g++ bug?!

I kid you not. Revert this and see src/test-map loop forever
eating your memory freezing your maching.

In this loop:

  {
    hb_hashmap_t<int, int> m0;
    hb_hashmap_t<std::string, int> m1;
    hb_hashmap_t<int, std::string> m2;
    hb_hashmap_t<std::string, std::string> m3;

    std::string s;
    for (unsigned i = 1; i < 1000; i++)
    {
      s += "x";
      m0.set (i, i);
      m1.set (s, i);
      m2.set (i, s);
      m3.set (s, s);
    }
  }

i will not stop at 1000 and just keeps going.  If you figure out
what's going on, please enlighten me!
pull/4228/head
Behdad Esfahbod 2 years ago
parent 9fbab46f26
commit 075ecff750
  1. 2
      src/hb-algs.hh

@ -317,7 +317,7 @@ struct
// Horrible: std:hash() of integers seems to be identity in gcc / clang?!
template <typename T,
hb_enable_if (std::is_integral<T>::value)> constexpr auto
impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, v * 8388607 /* Mersenne prime */)
impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, v * 8388607u /* Mersenne prime */)
template <typename T> constexpr auto
impl (const T& v, hb_priority<0>) const HB_RETURN (uint32_t, std::hash<hb_decay<decltype (hb_deref (v))>>{} (hb_deref (v)))

Loading…
Cancel
Save