RE: [Tinycc-devel] wrong preprocessor shift operation

2008-12-30 Thread Christian Jullien
0:08 To: tinycc-devel@nongnu.org Subject: Re: [Tinycc-devel] wrong preprocessor shift operation 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 corre

Re: [Tinycc-devel] wrong preprocessor shift operation

2008-12-30 Thread Dave Dodge
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

RE: [Tinycc-devel] wrong preprocessor shift operation

2008-12-30 Thread Christian Jullien
m: tinycc-devel-bounces+eligis=wanadoo...@nongnu.org [mailto:tinycc-devel-bounces+eligis=wanadoo...@nongnu.org] On Behalf Of grischka Sent: Tuesday, December 30, 2008 17:33 To: tinycc-devel@nongnu.org Subject: Re: [Tinycc-devel] wrong preprocessor shift operation Christian Jullien wrote: > Man

Re: [Tinycc-devel] wrong preprocessor shift operation

2008-12-30 Thread grischka
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

RE: [Tinycc-devel] wrong preprocessor shift operation

2008-12-30 Thread Christian Jullien
printf("fails %08x\n", (~0) >> 1); } Christian -Original Message- From: tinycc-devel-bounces+eligis=wanadoo...@nongnu.org [mailto:tinycc-devel-bounces+eligis=wanadoo...@nongnu.org] On Behalf Of grischka Sent: Tuesday, December 30, 2008 15:35 To: tinycc-devel@nongnu.org Subj

Re: [Tinycc-devel] wrong preprocessor shift operation

2008-12-30 Thread grischka
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

RE: [Tinycc-devel] wrong preprocessor shift operation

2008-12-30 Thread Christian Jullien
Of grischka Sent: Monday, December 29, 2008 19:59 To: tinycc-devel@nongnu.org Subject: Re: [Tinycc-devel] wrong preprocessor shift operation Christian Jullien wrote: > Simple code below is wrong, even when forcing to long or unsigned long : > > printf("%08x\n", ((~0) &

Re: [Tinycc-devel] wrong preprocessor shift operation

2008-12-29 Thread grischka
Christian Jullien wrote: Simple code below is wrong, even when forcing to long or unsigned long : printf("%08x\n", ((~0) >> 1)); printf("%08x\n", (unsigned long)((~(unsigned long)0) >> 1)); printf("%08x\n", (long)((~(long)0) >> 1)); It prints while

RE: [Tinycc-devel] wrong preprocessor shift operation

2008-12-28 Thread Christian Jullien
ter fix. You may also check if 0x is valid for TCC_TARGET_X86_64 Christian From: tinycc-devel-bounces+eligis=wanadoo...@nongnu.org [mailto:tinycc-devel-bounces+eligis=wanadoo...@nongnu.org] On Behalf Of Christian Jullien Sent: Sunday, December 28, 200

[Tinycc-devel] wrong preprocessor shift operation

2008-12-28 Thread Christian Jullien
Hello team, Simple code below is wrong, even when forcing to long or unsigned long : printf("%08x\n", ((~0) >> 1)); printf("%08x\n", (unsigned long)((~(unsigned long)0) >> 1)); printf("%08x\n", (long)((~(long)0) >> 1)); It prints while