public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: bkoz@gcc.gnu.org
To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org,
	vwhite@entercept.com
Subject: Re: libstdc++/8359: STL container can fault at runtime destroying contained objects with virtual destructors
Date: Thu, 31 Oct 2002 09:21:00 -0000	[thread overview]
Message-ID: <20021031172110.21251.qmail@sources.redhat.com> (raw)

Synopsis: STL container can fault at runtime destroying contained objects with virtual destructors

State-Changed-From-To: feedback->open
State-Changed-By: bkoz
State-Changed-When: Thu Oct 31 09:21:09 2002
State-Changed-Why:
    Just adding this bit.
    
    Without a test case, this bug report is so sufficiently vague as to be eligible for suspension.
    
    As an aid to you, I've provided a sample test case. It doesn't core. However, without the required copy constructor (vector requires all contained types to be both copyconstrible and assignable) you'll get a core. Perhaps this is what you are seeing?
    
    -benjamin
    
    #include <new>
    #include <vector>
    
    struct base
    {
    protected: 
      int i;
      char* p;
    
    public:
      base(int j = 0, const char* name = "hush hush"): i(j)
      {
        p = new char[strlen(name) + 1];
        strcpy(p, name);
      }
    
      ~base()
      { delete [] p; }
    };
    
    struct derived: public base
    {
      derived(int j2 = 5, const char* name2 = "mush mush"): base(j2, name2) { }
    
    #if 0
      // Define to make conformant to vector requirements.
      derived(const derived& dup)
      {
        i = dup.i;
        delete [] p;
        p = new char[strlen(dup.p) + 1];
        strcpy(p, dup.p);
      }
    
      derived&
      operator=(const derived& dup)
      {
        i = dup.i;
        delete [] p;
        p = new char[strlen(dup.p) + 1];
        strcpy(p, dup.p);
        return *this;
      }
    #endif
    };
    
    int main()
    {
      // Must be copyconstructible and assignable.
      std::vector<derived> vec(6);
      vec.push_back(derived(3, "blow up"));
      return 0;
    }

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8359


             reply	other threads:[~2002-10-31 17:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-31  9:21 bkoz [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-11-19 12:26 bkoz
2002-11-01  8:39 bkoz
2002-10-28 11:16 Victor White
2002-10-27 13:29 paolo
2002-10-25 13:06 vwhite

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=20021031172110.21251.qmail@sources.redhat.com \
    --to=bkoz@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    --cc=vwhite@entercept.com \
    /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).