Thanks for explanation.
My real code using unsigned was in fact something like:
printf("%08x\n", (~0U) >> 1);
That had broken result before my investigation and grischka fix and now
produces expected value on all compilers with my extreeemly portable
OpenLisp ISLISP implementation (see www.eligis
On Tue, Dec 30, 2008 at 05:32:57PM +0100, grischka wrote:
> Christian Jullien wrote:
>> printf("fails %08x\n", (~0) >> 1);
> fails
> Maybe gcc is not correct but then I need an exact explanation why ;)
0 has type int. On x86 the representation is 32 value bits set to
zero, with no
I've got the same result with VC++, LCC and DMC compiler so I assume it's
the correct behavior (I don't understand why).
Anyway, the reported bug is now fixed since my program correctly casts to
unsigned. Thanks for your time and your fix.
Christian
-Original Message-
From: tinycc-devel-
Christian Jullien wrote:
Many thanks, I tested your fix but I still have a broken case:
int
main()
{
unsigned int x = 0x;
unsigned int y = 1;
printf("fixed %08x\n", x >> y);
printf("fixed %08x\n", (~(unsigned int)0) >> (unsigned int)1);
printf("fa
Many thanks, I tested your fix but I still have a broken case:
int
main()
{
unsigned int x = 0x;
unsigned int y = 1;
printf("fixed %08x\n", x >> y);
printf("fixed %08x\n", (~(unsigned int)0) >> (unsigned int)1);
printf("fails %08x\n", (~0) >> 1);
}
Christian Jullien wrote:
I think you're right.
Bug occurs when int (0x) is promoted to long long
(0x). Then right shift and back to int conversion returns a
false result.
Another possible fix is to cast to (unsigned int) as with
if (t1 == VT_LLONG) {
l1 = v1->c.ll;
} e
I think you're right.
Bug occurs when int (0x) is promoted to long long
(0x). Then right shift and back to int conversion returns a
false result.
Another possible fix is to cast to (unsigned int) as with
if (t1 == VT_LLONG) {
l1 = v1->c.ll;
} else {
l1 = (unsigned int