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

            Bug ID: 109920
           Summary: value-range.h: Mismatched new [] and delete
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

I just did a valgrind build of gcc trunk. It said

=91612== Mismatched free() / delete / delete []
==91612==    at 0x484498A: operator delete(void*, unsigned long)
(vg_replace_malloc.c:1072) 
==91612==    by 0x18D285B: ~int_range (value-range.h:493)
==91612==    by 0x18D285B: ~Value_Range (value-range.h:516)
==91612==    by 0x18D285B: ranger_cache::fill_block_cache(tree_node*,
basic_block_def*, basic_block_def*) (gimple-range-cache.cc:1479)

Source code is

inline void
irange::maybe_resize (int needed)
{  
  if (!m_resizable || m_max_ranges == HARD_MAX_RANGES)
    return;

  if (needed > m_max_ranges)
    {
      m_max_ranges = HARD_MAX_RANGES;
      wide_int *newmem = new wide_int[m_max_ranges * 2];
      memcpy (newmem, m_base, sizeof (wide_int) * num_pairs () * 2);
      m_base = newmem;
    }
}

template<unsigned N, bool RESIZABLE>
inline
int_range<N, RESIZABLE>::~int_range ()
{
  if (RESIZABLE && m_base != m_ranges)
    delete m_base;
}

Note use of new [] and delete.

Reply via email to