public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: paolo@gcc.gnu.org To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, john.carter@tait.co.nz, nobody@gcc.gnu.org Subject: Re: libstdc++/7961: compare( char *) implemented incorrectly. Date: Fri, 01 Nov 2002 02:23:00 -0000 [thread overview] Message-ID: <20021101102328.10093.qmail@sources.redhat.com> (raw) 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 <string> #include <cassert> 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
next reply other threads:[~2002-11-01 10:23 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-11-01 2:23 paolo [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-11-01 7:27 paolo 2002-11-01 2:55 paolo 2002-11-01 2:36 paolo 2002-09-18 14:46 John Carter 2002-09-18 14:36 John Carter 2002-09-18 1:46 Andreas Schwab 2002-09-17 20:36 john.carter
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=20021101102328.10093.qmail@sources.redhat.com \ --to=paolo@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ --cc=gcc-gnats@gcc.gnu.org \ --cc=gcc-prs@gcc.gnu.org \ --cc=john.carter@tait.co.nz \ --cc=nobody@gcc.gnu.org \ /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).