[James W.McKelvey <mckelvey@maskull.com>] Erroneous Comparisons of Negative Characters
Paolo Carlini
pcarlini@suse.de
Mon May 3 11:06:00 GMT 2004
Thankg Gaby for the forward!
>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
>
>
This /C standard conforming behavior/ (C99, 7.21.4, p1) seems at the
heart of the problem.
Indeed, a pedantic interpretation of Table 37 appear to imply that the C
functions, always defined in terms of /unsigned/ chars, cannot be used
for implementing traits::compare. And, we cannot overlook this as a
futile technicality (*), since, according to the current standard,
traits::compare /must/ be used in implementing string::compare.
Shall we perhaps fall back to the slow generic implementation, following
the letter of the standard? Personally, I'm not happy with this either,
since string::compare would give results different from std::strcmp!
What do other people think?
Paolo.
(*) I know that nobody likes that much char_traits today... ;)
More information about the Libstdc++
mailing list