[openib-general] Re: [PATCH] Fix ib_pack/unpack for 64 bits

Roland Dreier roland at topspin.com
Thu Jun 23 12:37:50 PDT 2005


    Grant> If so, then gcc or the code gen backend should generate a
    Grant> warning about overflowing the encoding.  This sounds like a
    Grant> toolchain bug.

gcc does generate a warning for constant shifts that are too big, as in:

	bit = 1ull << 64;

No diagnostic is generated when the shift is a variable, as in

	bit = 1ull << shift;

If at runtime, shift is bigger than the width of the unsigned long
long type, then this expression is undefined according to the C spec.
So the gcc behavior is perfectly correct.

 - R.



More information about the general mailing list