[Assist] GCC extreme bit-shift by constant vs. by variable

Rudolf Dovičín rudolf.dovicin at gmail.com
Tue Oct 14 19:30:19 BST 2014


Hello.

In GCC (version 4.9.1 20140903 on x86_64) when I write
1u << 32u;
I will get correct result 0u.

But if I write
unsigned thirty_two_unsigned = 32u;
1u << thirty_two_unsigned;
I will get incorrect result 1u.

(It is the same in the right-shift.)

I do not know if it is an error or regular behaviour (i. e. undefined
by ANSI/ISO C).
-- 
Rudolf Dovičín
Partizánska 1506/92-34
957 01  Bánovce nad Bebravou 1
SLOVENSKO
xmpp: ruwolf at jabbim.sk
(cellular: +421 944 748308, short messages only)


More information about the Assist mailing list