public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Trevor Saunders <tbsaunde@tbsaunde.org>
To: tbsaunde+gcc@tbsaunde.org, gcc-patches@gcc.gnu.org,
	rguenther@suse.de,	rdsandiford@googlemail.com
Subject: Re: [PATCH 1/2] destroy values as well as keys when removing them from hash maps
Date: Wed, 02 Dec 2015 05:04:00 -0000	[thread overview]
Message-ID: <20151202050346.GA29495@tsaunders-iceball.corp.tor1.mozilla.com> (raw)
In-Reply-To: <87wpsy3qfs.fsf@googlemail.com>

On Tue, Dec 01, 2015 at 07:43:35PM +0000, Richard Sandiford wrote:
> tbsaunde+gcc@tbsaunde.org writes:
> > -template <typename H>
> > +template <typename H, typename Value>
> >  template <typename T>
> >  inline void
> > -simple_hashmap_traits <H>::remove (T &entry)
> > +simple_hashmap_traits <H, Value>::remove (T &entry)
> >  {
> >    H::remove (entry.m_key);
> > +  entry.m_value.~Value ();
> >  }
> 
> This is just repeating my IRC comment really, but doesn't this mean that
> we're calling the destructor on an object that was never constructed?
> I.e. nothing ever calls placement new on the entry, the m_key, or the
> m_value.

I believe you are correct that placement new is not called.  I'd say its
a bug waiting to happen given that the usage of auto_vec seems to
demonstrate that people expect objects to be initialized and destroyed.
However for now all values are either POD, or auto_vec and in either
case the current 0 initialization has the same effect as the
constructor.  So There may be a theoretical problem with how we
initialize values that will become real when somebody adds a constructor
that doesn't just 0 initialize.  So it should probably be improved at
some point, but it doesn't seem necessary to mess with it at this point
instead of next stage 1.

Trev

> 
> Thanks,
> Richard

  reply	other threads:[~2015-12-02  5:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-24  5:41 tbsaunde+gcc
2015-11-24  5:53 ` [PATCH 2/2] remove val_ssa_equiv_hash_traits tbsaunde+gcc
2015-11-24  8:36   ` Richard Biener
2015-11-24  8:34 ` [PATCH 1/2] destroy values as well as keys when removing them from hash maps Richard Biener
2015-12-01 19:43 ` Richard Sandiford
2015-12-02  5:04   ` Trevor Saunders [this message]
2015-12-02  8:57     ` Richard Biener
2015-12-02  9:35       ` Richard Sandiford
2015-12-02 20:00         ` Trevor Saunders

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=20151202050346.GA29495@tsaunders-iceball.corp.tor1.mozilla.com \
    --to=tbsaunde@tbsaunde.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rdsandiford@googlemail.com \
    --cc=rguenther@suse.de \
    --cc=tbsaunde+gcc@tbsaunde.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).