This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Erroneous Comparisons of Negative Characters
- From: llewelly at xmission dot com
- To: mckelvey at maskull dot com
- Cc: gcc-help at gcc dot gnu dot org
- Date: 02 May 2004 06:05:50 -0600
- Subject: Re: Erroneous Comparisons of Negative Characters
- References: <04050120044300.28968@alpha1>
James W. McKelvey <mckelvey@maskull.com> writes:
> When chars are implemented as signed, characters with negative values compare
> properly as individual chars, but improperly when part of a char array or
> std::string -- they compare as unsigned. The problem appears to be that the
> specialization of std::char_traits<char> uses memcmp. This is observed on an
> Alpha running RH 7.1 and gcc version 3.5.0 20040207.
I see the same behavior with gcc 3.4.0 on i686-freeBSD5.2
>
> Specifically, std::char_traits<char>::compare is inconsistent with
> std::char_traits<char>::lt, which affects std::string (which is just
> std::basic_string<char>.) The problem also affects strcmp, strncmp, and
> strcoll.
[snip]
std::char_traits<char>::compare is defined in terms of
std::char_traits<char>::lt in 21.1.1/1 table 37, and I can't find
a reason why they might be allowed to be inconsistent.
I think you should report a bug, see gcc.gnu.org/bugs.html