B
boltar2003
hi
Can someone tell me whats going on here. I'm using gcc 4.3.3 in linux.
Have I missed something obvious in the code snippet below or is there some
odd casting bug going on with gcc?
$ cat t.c
#include <stdio.h>
main()
{
double d = -2.345;
printf("%f\n",(double)(1 ? (int)d : (unsigned int)1));
}
$ cc t.c
$ ./a.out
4294967294.000000
If you change unsigned int to unsigned char then you get -2 as expected as
the result.
B2003
Can someone tell me whats going on here. I'm using gcc 4.3.3 in linux.
Have I missed something obvious in the code snippet below or is there some
odd casting bug going on with gcc?
$ cat t.c
#include <stdio.h>
main()
{
double d = -2.345;
printf("%f\n",(double)(1 ? (int)d : (unsigned int)1));
}
$ cc t.c
$ ./a.out
4294967294.000000
If you change unsigned int to unsigned char then you get -2 as expected as
the result.
B2003