comp.lang.c
[Top] [All Lists]

Re: Strange bit shifting result with gcc - am I missing something obvio

Subject: Re: Strange bit shifting result with gcc - am I missing something obvious?
From: Eric Sosman
Date: Sun, 30 Mar 2008 17:18:33 -0400
Newsgroups: comp.lang.c


Boltar wrote:
On 30 Mar, 21:37, jacob navia <ja...@xxxxxxxxxx> wrote:
The result of shifting more than sizeof(int)*CHAR_BIT positions
is NOT defined by the language. It is an illegal expression.

It isn't? Thats bloody annoying since that means i'll have to do a
specific check for the bit shift count being > than the size of the
type being shifted.

    Actually, you need to check for >=, not just >.  And
with signed integers, you need to be sure the value being
shifted is non-negative and small enough that no 1's are
propagated into the sign position.

--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy