This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC 3.1.1
- From: Jamie Lokier <egcs at tantalophile dot demon dot co dot uk>
- To: Rob Taylor <robt at flyingpig dot com>, Andreas Schwab <schwab at suse dot de>, 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: Sun, 7 Jul 2002 22:48:09 +0100
- Subject: Re: GCC 3.1.1
- References: <je660326xk.fsf@sykes.suse.de> <020a01c21e8d$45433690$9b00a8c0@highend.co.uk> <20020628103059.GA15129@falcon.midgard.homeip.net>
Erik Trulsson wrote:
> x is an unsigned long long, yes, but 1 is not. An unadorned 1 has type
> int. This means that the RHS of the expression above has type int and
> will be evaluated as such. (And if an int has 32 bits or less the
> expression won't be well-defined.) This value will then be assigned to
> x. In C the type of a variable on the left side of an assignment does
> not influence how the right hand side is evaluated.
>
> If you want the expression to work "as expected" I think
> x = 1LL << 32
> should do the trick.
Note that 1LL << 63 is not well-defined (although it is fine with GCC).
1ULL << 63 is well-defined, though, and it would seem to make more sense
in this example because x is unsigned.
-- Jamie