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.

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to