This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Shifting: what's going on?


Hi Facundo,

> I expect to get a 1 in the s-th bit of a, and zeroes in all other
> bits. I don't know why you say that's an arithmetic overflow, if
> unsigned long long is 64 bits long and it has a 63-th bit (the last
> one).

You are not dealing with an unsigned long long that is 64-bits.

You are dealing with a signed int that is 32-bits.

Shifting a number by an amount equal-to-or-greater-than its bitsize has
undefined behavior.

--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]