[Linux-ia64] Re: Port of the posix timers to IA64

From: David Mosberger <davidm_at_napali.hpl.hp.com>
Date: 2003-03-01 19:10:03
Hi Eric,

>>>>> On Fri, 28 Feb 2003 10:52:33 +0100, Eric Piel <Eric.Piel@Bull.Net> said:

  Eric> long v;
  Eric> :
  Eric> :
  Eric> if ( v >= (1 << 56)){
  Eric> :
  Eric> }

  Eric> It seems very strange for me that when compiling this part gcc
  Eric> considers that eveything must be converted to int. I have to
  Eric> write 1UL instead of 1 in order to obtain the correct
  Eric> behaviour of the code. I guess you've already come along with
  Eric> such problem.

As Andreas pointed out, that's just how C works.

  Eric> So, first, do you think it's a bug in gcc?

No, gcc is doing the Right Thing.

  Eric> Second should I convert every 1's I see by 1UL's (there are
  Eric> only few but sounds so strange)?

Yes, you need to make sure that anything that gets shifted more than
32 bits has the proper type.  In portable code, I sometimes prefer
to use explicit type-casts, e.g.:

	((size_t) 1) << 48

if the final value needs to be of type size_t, but that's largely
a matter of taste.

	--david
Received on Sat Mar 01 00:11:41 2003

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:12 EST