Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 61569 invoked from network); 20 Sep 2007 22:40:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Sep 2007 22:40:23 -0000 Received: (qmail 34963 invoked by uid 500); 20 Sep 2007 22:40:14 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 34948 invoked by uid 500); 20 Sep 2007 22:40:14 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 34937 invoked by uid 99); 20 Sep 2007 22:40:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2007 15:40:14 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.quovadx.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2007 22:40:14 +0000 Received: from qxvcexch01.ad.quovadx.com ([192.168.170.59]) by moroha.quovadx.com (8.13.6/8.13.6) with ESMTP id l8KMdKhw006153 for ; Thu, 20 Sep 2007 22:39:20 GMT Received: from [10.70.3.113] ([10.70.3.113]) by qxvcexch01.ad.quovadx.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 20 Sep 2007 16:39:51 -0600 Message-ID: <46F2F6B8.4060304@roguewave.com> Date: Thu, 20 Sep 2007 16:39:52 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4 MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: [PATCH] Add overflow checking to basic_string append and push_back References: <46F2D039.5070508@roguewave.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 20 Sep 2007 22:39:51.0472 (UTC) FILETIME=[28391B00:01C7FBD7] X-Virus-Checked: Checked by ClamAV on apache.org Travis Vitek wrote: [...] >> The change also seems unnecessary -- when size() equals capacity() >> we check that it doesn't exceed max_size() before allocating more >> memory in append(). Otherwise, when size() is less than capacity() >> (or rather capacity() - 1), there should be no reason to check >> against max_size() because we know that capacity() must have >> been below max_size() the last time we reallocated. > > If that is the case, then why would we possibly need this same code in > any of the other methods that are used to extend the original string? I don't think we do, really. I suspect the main reason why the code is in all other (out-of-line) modifiers is so we can throw the exception from function that is called directly by program rather than from the one that happens to be called from it to do the real work (all roads lead to replace()). I think the test case has some problems but I just saw your update so I'll follow up on it there. Martin