From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10161 invoked by alias); 1 Nov 2002 10:23:30 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 10095 invoked by uid 61); 1 Nov 2002 10:23:28 -0000 Date: Fri, 01 Nov 2002 02:23:00 -0000 Message-ID: <20021101102328.10093.qmail@sources.redhat.com> To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, john.carter@tait.co.nz, nobody@gcc.gnu.org From: paolo@gcc.gnu.org Reply-To: paolo@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, john.carter@tait.co.nz, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: libstdc++/7961: compare( char *) implemented incorrectly. X-SW-Source: 2002-11/txt/msg00003.txt.bz2 List-Id: Synopsis: compare( char *) implemented incorrectly. State-Changed-From-To: open->closed State-Changed-By: paolo State-Changed-When: Fri Nov 1 02:23:27 2002 State-Changed-Why: Not a bug. Indeed, no segfaults can be produced at run-time with code like the following // ------------ #include #include int main() { std::string lhs("abc"); lhs.append(1, '\0'); lhs += "def"; assert( lhs != "abc" ); } // ------------- and variants thereof. From the glibc2.3.1 documentation: - Function: int memcmp (const void *A1, const void *A2, size_t SIZE) The function `memcmp' compares the SIZE bytes of memory beginning at A1 against the SIZE bytes of memory beginning at A2. The value returned has the same sign as the difference between the first differing pair of bytes (interpreted as `unsigned char' objects, then promoted to `int'). If the contents of the two blocks are equal, `memcmp' returns `0'. that is, it seems to me that there is absolutely *nothing* wrong with a '\0' embedded in the string: its just a byte like any other. Thanks for your report, Paolo. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7961