This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC 3.1.1
- From: Dale Johannesen <dalej at apple dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: Dale Johannesen <dalej at apple dot com>, Jack Lloyd <lloyd at acm dot jhu dot edu>, Toon Moene <toon at moene dot indiv dot nluug dot nl>, gcc at gcc dot gnu dot org, shimon at simon-shapiro dot com
- Date: Fri, 28 Jun 2002 11:01:37 -0700
- Subject: Re: GCC 3.1.1
On Friday, June 28, 2002, at 12:33 AM, Andreas Schwab wrote:
Jack Lloyd <lloyd@acm.jhu.edu> writes:
|> Basically:
|>
|> unsigned long long x;
|> x = 1 << 32;
|>
|> results in x == 0 rather than 0x100000000 as the code expects.
Actually this is already undefined by itself, and even x == 0 is not
guaranteed.
Yes. It will be 1 on some machines (when the shift count is truncated
to 5 bits, thus 0). The result may vary with optimization level, and
depend on whether the 1 or the 32 is a constant or in a variable.
In short, don't do that.
1LL << 32 should do what you want.