public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: theonetruekenny@yahoo.com To: gcc-gnats@gcc.gnu.org Cc: kenny.simpson@gs.com Subject: libstdc++/3946: auto_ptr_ref constructor allows dangerous conversion Date: Sun, 05 Aug 2001 15:26:00 -0000 [thread overview] Message-ID: <20010805222450.6754.qmail@sourceware.cygnus.com> (raw) >Number: 3946 >Category: libstdc++ >Synopsis: auto_ptr_ref constructor allows dangerous conversion >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sun Aug 05 15:26:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Kenny Simpson >Release: online compiler (gcc version 3.0.1 20010626 (prerelease)) and 8-05-2001 CVS >Organization: >Environment: online compiler >Description: auto_ptr_ref<T>'s constructor allows conversion from T*. auto_ptr<U> has a member operator=( auto_ptr_ref<T>). This effectively adds a member operator=(T*) to auto_ptr. I believe this to be neither intentional, nor desirable. >From http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#127 : auto_ptr& operator=(auto_ptr_ref<X> r) throw() Effects: Calls reset(p.release()) for the auto_ptr p that r holds a reference to. Returns: *this. This implies that auto_ptr_ref's must have an associated auto_ptr, but allowing an auto_ptr_ref to be constructed for any pointer defeats this. >How-To-Repeat: #include <memory> int main() { std::auto_ptr<int> a; int* b = new int(3); a = b; // this should NOT compile return 0; } >Fix: on line 62 of include/bits/std_memory.h change: auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {} to explicit auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {} >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2001-08-05 15:26 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-08-05 15:26 theonetruekenny [this message] 2002-07-04 10:05 bkoz
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=20010805222450.6754.qmail@sourceware.cygnus.com \ --to=theonetruekenny@yahoo.com \ --cc=gcc-gnats@gcc.gnu.org \ --cc=kenny.simpson@gs.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: linkBe 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).