Errm, well, this seems not to be my day. Sure it is promoted to wider scalar.
Small test-program run under Windows 64-bit (using gcc 4.7) shows
#include <stdio.h>
static const size_t npos1 = -1;
static const size_t npos2 = static_cast<size_t>(-1);
int main ()
{
unsigned int p = ~0U;
printf ("npos1 = 0x%I64X\n", npos1);
printf ("npos2 = 0x%I64X\n", npos2);
printf ("(unsigned int) p is 0x%X\n", p);
printf ("p == npos1 is %s\n", (p == npos1 ? "true" : "false"));
printf ("p == npos2 is %s\n", (p == npos2 ? "true" : "false"));
return 0;
}
as output
$ ./tst.exe
npos1 = 0xFFFFFFFFFFFFFFFF
npos2 = 0xFFFFFFFFFFFFFFFF
(unsigned int) p is 0xFFFFFFFF
p == npos1 is false
p == npos2 is false
And this is the expected output. So maybe a wrong code bug in gcc, indeed.
Kai
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public