Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 66521 invoked from network); 12 Mar 2006 00:11:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Mar 2006 00:11:42 -0000 Received: (qmail 19775 invoked by uid 500); 12 Mar 2006 00:11:41 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 19747 invoked by uid 500); 12 Mar 2006 00:11:41 -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 19736 invoked by uid 99); 12 Mar 2006 00:11:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Mar 2006 16:11:41 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.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; Sat, 11 Mar 2006 16:11:39 -0800 Received: from bco-exchange.bco.roguewave.com (bco-exchange.bco.roguewave.com [172.19.31.48]) by moroha.quovadx.com (8.13.4/8.13.4) with ESMTP id k2C09gUh021219 for ; Sun, 12 Mar 2006 00:09:43 GMT Received: from [10.70.3.113] (10.70.3.113 [10.70.3.113]) by bco-exchange.bco.roguewave.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id F5YGRVZR; Sat, 11 Mar 2006 17:10:04 -0700 Message-ID: <44136831.7060602@roguewave.com> Date: Sat, 11 Mar 2006 17:15:45 -0700 From: Martin Sebor User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 X-Accept-Language: en-us, en MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: test for 21.strings.capacity References: <4D6A8407B7AC6F4D95B0E55C4E7C4C6203D3DF93@exmsk.moscow.vdiweb.com> In-Reply-To: <4D6A8407B7AC6F4D95B0E55C4E7C4C6203D3DF93@exmsk.moscow.vdiweb.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Anton Pevtsov wrote: > The linker error disappears, thanks! > > But, unfortunately, the problems with UserTraits members occurred: Yep, these are more of my screwups. I should have finished the test before making the changes... > > 1) char.cpp, line 132, the copy() member function: > ... > for (size_t i = 0; i != n; dst [i] = src [i]); > ... > > This is the endless loop. I think it should be changed to something like > this: > ... > for (size_t i = 0; i != n; dst [i] = src [i++]); This won't work because modifying the same variable (i above) in the same expression (or, more precisely, between two subsequent sequence points) has undefined behavior. > ... > > 2) char.cpp, line 146, the move() member function: > ... > for (; n--; dst [n] = src [n]); > ... > > This code doesn't work properly. E.g. move when > dst = "abc", src = "bc", n = 2, dst and src points to the same string, > results in "cc", but "bc" is expected. > > I use the following code instead: > ... > if (dst < src) { > while (n--) > *dst++ = *src++; > } > else { > for (dst += n, src += n; n--; ) > *--dst = *--src; > } > ... Thanks! I fixed both problems with the commit below: http://svn.apache.org/viewcvs?rev=385211&view=rev The test is here. It still needs to be enhanced to cover the remaining member functions of UserTraits as well as the other two specializations of the template. Feel free to post patches with those enhancements or any other extensions to it. http://svn.apache.org/viewcvs?rev=385210&view=rev Martin