Print

Print


Isn't there some suffix like L to add instead of doing a cast?

On Tue, 14 Sep 2004, Andrew Hanushevsky wrote:

> 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
>

--
 /------------------------------------+-------------------------\
|Stephen J. Gowdy                     | SLAC, MailStop 34,       |
|http://www.slac.stanford.edu/~gowdy/ | 2575 Sand Hill Road,     |
|http://calendar.yahoo.com/gowdy      | Menlo Park CA 94025, USA |
|EMail: [log in to unmask]       | Tel: +1 650 926 3144     |
 \------------------------------------+-------------------------/