public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/15276] New: Erroneous Comparisons of Negative Characters
@ 2004-05-04  4:51 mckelvey at maskull dot com
  2004-05-04  4:53 ` [Bug libstdc++/15276] " mckelvey at maskull dot com
                   ` (38 more replies)
  0 siblings, 39 replies; 40+ messages in thread
From: mckelvey at maskull dot com @ 2004-05-04  4:51 UTC (permalink / raw)
  To: gcc-bugs

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.

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.


Result of running test program, with my analysis:

122      Expected character value of 'z'.
-64      Expected value of signed character '\0300'
192      Expected value of unsigned character '\0300'
-64      Shows that chars are signed

SC 1    Expected character comparison as signed char
UC 0    Expected character comparison as unsigned char
CH 1    Expected character comparison as char (signed)
SV 1    Demonstrates that std::string::value_type is signed
ST 0    Error: std::string of length 1 does not compare the same as CH
BS 1    std::basic_string<signed char> compares as expected
BU 0    std::basic_string<unsigned char> compares as expected
BC 0    Error: Same as ST, as expected (std::basic_string<char>)
TS 1    std::char_traits<signed char> compares signed char * as expected
TU 0    std::char_traits<signed char> compares unsigned char * as expected
TC 0    Error: std::char_traits<char>, char * does not compare properly
LS 1    std::char_traits<signed char> compares signed char as expected
LU 0    std::char_traits<unsigned char> compares unsigned char as expected
LC 1    std::char_traits<char> compares char as expected
          (Note: inconsistent with TC)
MC 0   std::memcmp is comparing as unsigned (I guess that's OK)
SC 0    Error: std::strcmp is comparing as unsigned
SN 0    Error: std::strncmp is comparing as unsigned
SL 0     Error: std::strcoll is comparing as unsigned

-- 
           Summary: Erroneous Comparisons of Negative Characters
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mckelvey at maskull dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: alphaev56-unknown-linux-gnu
  GCC host triplet: alphaev56-unknown-linux-gnu
GCC target triplet: alphaev56-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15276


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2005-04-17 18:17 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-04  4:51 [Bug libstdc++/15276] New: Erroneous Comparisons of Negative Characters mckelvey at maskull dot com
2004-05-04  4:53 ` [Bug libstdc++/15276] " mckelvey at maskull dot com
2004-05-04  5:15 ` pinskia at gcc dot gnu dot org
2004-05-04  9:33 ` pcarlini at suse dot de
2004-05-05  3:18 ` mckelvey at maskull dot com
2004-05-05  8:27 ` pcarlini at suse dot de
2004-05-05  8:40 ` gdr at integrable-solutions dot net
2004-05-05  9:43 ` pcarlini at suse dot de
2004-05-05  9:56 ` pcarlini at suse dot de
2004-05-05 10:24 ` gdr at integrable-solutions dot net
2004-05-05 10:38 ` gdr at integrable-solutions dot net
2004-05-05 10:53 ` pcarlini at suse dot de
2004-05-05 11:07 ` pcarlini at suse dot de
2004-05-05 11:42 ` gdr at integrable-solutions dot net
2004-05-05 12:05 ` pcarlini at suse dot de
2004-05-05 14:55 ` gdr at integrable-solutions dot net
2004-05-05 15:19 ` pcarlini at suse dot de
2004-05-05 16:21 ` bangerth at dealii dot org
2004-05-05 16:44 ` gdr at integrable-solutions dot net
2004-05-05 17:12 ` pcarlini at suse dot de
2004-05-05 17:27 ` gdr at integrable-solutions dot net
2004-05-05 17:35 ` pcarlini at suse dot de
2004-05-05 17:36 ` sebor at roguewave dot com
2004-05-05 17:39 ` pcarlini at suse dot de
2004-05-05 17:52 ` sebor at roguewave dot com
2004-05-05 18:26 ` pcarlini at suse dot de
2004-05-05 18:28 ` gdr at integrable-solutions dot net
2004-05-05 18:32 ` gdr at integrable-solutions dot net
2004-05-05 18:35 ` gdr at integrable-solutions dot net
2004-05-05 18:42 ` pcarlini at suse dot de
2004-05-05 18:56 ` pcarlini at suse dot de
2004-05-05 19:14 ` pcarlini at suse dot de
2004-05-05 23:00 ` gdr at integrable-solutions dot net
2004-05-05 23:02 ` gdr at integrable-solutions dot net
2004-05-06  8:04 ` pcarlini at suse dot de
2004-06-20  9:48 ` pcarlini at suse dot de
2004-06-20  9:52 ` pcarlini at suse dot de
2004-07-26 21:11 ` pinskia at gcc dot gnu dot org
2004-08-05 10:59 ` [Bug libstdc++/15276] [DR 467] " pcarlini at suse dot de
2005-04-17 18:17 ` pcarlini at suse dot de

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).