Hi Roland,
On Thu, 2006-09-21 at 10:12 +0200, Roland Kuhn wrote:
> Hi Christian!
>
> On 21 Sep 2006, at 02:33, Christian Holm Christensen wrote:
>
> > Hi Tobi,
> >
> > On Wed, 2006-09-20 at 12:23 -0500, Tobias Raufer wrote:
> >> Hi RootTalk,
...
> > Believe it or not, but 4294967295 and -1 are the same :) If you do
> >
> No, they ain't.
Perhaps you need to read my mail again a bit more carefully. What matters is the promotion/demotion done - not what the actual types are. Try compiling the attached code and run it. I get on my Debian GNU/Linux unstable (sid) i386 box, with GCC 4.1.2:
> g++ foo.cc -o foo && ./foo j j unsigned unsigned int a (-1) is equal to b (4294967295)
(`j' is GCC's mangled name for `unsigned').
So it seems that GCC also thinks that -1 and 4294967295 is the same. If you think that's incorrect, I suggest you take that up with the GCC developers :)
> CINT is incorrect in providing string::npos as signed
> integer. It does not matter that the bits in the i386 representation
> are the same, the types of string::npos and string::find() must be
> identical because they're meant to be compared.
You are right iff you where to do ordered compares (<, >, >=, <=), but there's nothing in the standard that guarantees that you can do an ordered compare to std::string::npos - in fact, I'd argue that it would be conceptually wrong to do that.
> The STL takes care to get this right, so it must be a bug in CINT.
Just why is it a bug? If I can use std::string::npos as I'm supposed to, like
std::string foo("foo"); assert(foo.find("bar") == std::string::npos); assert(foo.find("foo") != std::string::npos);
then I have a hard to classifying this as a bug - it's doing as expected by the standard.
Yours,
-- ___ | Christian Holm Christensen |_| | ------------------------------------------------------------- | | Address: Sankt Hansgade 23, 1. th. Phone: (+45) 35 35 96 91 _| DK-2200 Copenhagen N Cell: (+45) 24 61 85 91 _| Denmark Office: (+45) 353 25 404 ____| Email: cholm_at_nbi.dk Web: www.nbi.dk/~cholm | |Received on Fri Sep 22 2006 - 00:51:12 MEST
- text/x-c++src attachment: foo.cc__charset_ISO-8859-15
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET