> check the ASM, looks like c is being cast as signed and then sign
> extended into a long and then ORed with l.
> 
> perhaps this would solve it :
> 
> l |= ((unsigned long) c) << 24

that works.  the extra () are unnecessary.

i think that gcc is using 6.3.1.1 and converting
c to an int (since it fits) so the original expression
is evaulated as
        (int)0xab << (int)24
        -> (int)0xab000000
if there is any sign extension here, it is shifted
away.  then gcc sign-extends this into 8 bytes,
giving the value you see.

- erik

Reply via email to