Comment 1 for bug 24762

Revision history for this message
Matthias Klose (doko) wrote :

(In reply to comment #0)
> // this code can be found at http://cjb.ie/gcc-bug.c or
http://cjb.ie/gcc-bug.c.txt
>
> #include <stdio.h>
>
> int main ( int argc, char *argv[] )
> { long long a;
> int b=40;
> a=1<<40; // this generates "warning: left shift count >= width of type",

correct, the right hand side has type int.

> // but no warning about result of 32 bit expression being
> implicitly promoted to 64.

correct, you don't get a warning for promotion to the bigger type.

> // this sets a=1.
> printf( "a = %llx\n", a );
> a=1<<b; // this generates no warning at all, and sets
> a=1<<(b%32)=0x100 (different to the above case).

correct behaviour.

> printf( "a = %llx\n", a );
> a=1LL<<b; // this works as intended, seting a=0x10000000000
> printf( "a = %llx\n", a );
> }
>
> // I've only tried this with <<, but I'd imagine other operators -
> multiplication, for example - are similarly affected.