libstdc++/7961: compare( char *) implemented incorrectly.
Fri Nov 1 02:23:00 GMT 2002
Synopsis: compare( char *) implemented incorrectly.
State-Changed-When: Fri Nov 1 02:23:27 2002
Not a bug.
Indeed, no segfaults can be produced at run-time with code
like the following
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.
More information about the Gcc-bugs