Print

Print


Hi Stephen,

Yes, you can suffix "ll" to the constant. I'm not sure if that's portable,
necessarily. Even if it were, that would force you to know what the type
of the server mask was. All the code in the olbd hides the type so that if
it ever were necessary to make it bigger than 64 bits, you can easily do
so. So, the more consistent way of doing it is to simply declare a const
value of the right type initialized to one.

Andy

On Tue, 14 Sep 2004, Stephen J. Gowdy wrote:

> 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     |
>  \------------------------------------+-------------------------/
>