Print

Print


Hi Pete,

Problem solved. This is a compiler bug. Well, let's say it wasn't
specified correctly in the ANSI standard and you wind up with a bug. The
details are:

long long x;

x = 1<<y;

will be interpreted by the compiler to mean

x = 1 << (y % (sizeof(1)*sizeof(char)));

Well, sizeof(1) is 4 since it's an int; so shifts greater than 32 will
wrap. That's the bug. The claim is that the compiler errored because it
should have promoted 1 to a long long and it doesn't. The same is true in
Sun CC as well as g++. This bug has been reported but apparently no one
has seen fit to fix it yet (as far as I can tell there is disagreement on
what the standard really meant).

The solution is to forcibly cast "1" to a long long, sigh. I will fix this
and commit. I hope no one coded this in BaBar code.

Andy