[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Buggy left shift on x86_64

From: Thomas Preud'homme
Subject: Re: [Tinycc-devel] Buggy left shift on x86_64
Date: Tue, 13 Mar 2012 17:34:09 +0100
User-agent: KMail/1.13.7 (Linux/3.2.0-2-amd64; KDE/4.7.4; x86_64; ; )

Le mardi 13 mars 2012 17:02:24, Vincent Lefevre a écrit :
> On 2012-03-13 16:49:37 +0100, Vincent Lefevre wrote:
> > FYI, the problem occurs for shift counts from 32 to 63 (larger
> > shift counts are invalid in C, since the variable is on 64 bits).
> The bug disappears when I replace 1UL by: (unsigned long) 1
> And the bug occurs with:
>   m = (1UL << (SH/2)) * (1UL << (SH/2));
> So, it seems that the problem is not the left shift, but the fact
> that tcc does not regard 1UL as an unsigned long (64 bits).

Thanks for the input. The issue seems to be in tccpp.c parse_number function. 
The code seems to assume that UL is unsigned int. The code I'm refering to is:

                if (lcount == 2) {
                    if (tok == TOK_CINT)
                        tok = TOK_CLLONG;
                    else if (tok == TOK_CUINT)
                        tok = TOK_CULLONG;

We could add an ifdef statement to only do the lcount == 2 test if it's a 32 
bit system but it seems really dirty. Or maybe targets could define the 
programming model (LP64 & Co) and this could be use here.

Grishka, what do you think is the best approach?

Attachment: signature.asc
Description: This is a digitally signed message part.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]