public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dcb314 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/109920] New: value-range.h: Mismatched new [] and delete
Date: Sun, 21 May 2023 08:08:09 +0000	[thread overview]
Message-ID: <bug-109920-4@http.gcc.gnu.org/bugzilla/> (raw)

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	other threads:[~2023-05-21  8:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-21  8:08 dcb314 at hotmail dot com [this message]
2023-05-21  8:10 ` [Bug c/109920] " dcb314 at hotmail dot com
2023-05-21 17:23 ` [Bug tree-optimization/109920] [14 Regression] " pinskia at gcc dot gnu.org
2023-05-22 19:03 ` aldyh at gcc dot gnu.org
2023-05-22 19:36 ` dcb314 at hotmail dot com
2023-05-23  6:56 ` cvs-commit at gcc dot gnu.org
2023-05-23  6:58 ` aldyh at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109920-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).