This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: bit shift bug with GCC 2.95.2 19991024 under Solaris 7
- To: andrew at ncbi dot nlm dot nih dot gov
- Subject: Re: bit shift bug with GCC 2.95.2 19991024 under Solaris 7
- From: Richard Henderson <rth at redhat dot com>
- Date: Tue, 9 Jan 2001 00:38:10 -0800
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <wensnmthj54.fsf@ncbi.nlm.nih.gov>
On Mon, Jan 08, 2001 at 03:40:55PM -0500, John S. J. Anderson wrote:
> (note the incorrect spike). Based on ANSI C Standard, when doing a bit
> shift, both sides should be promoted to the most significant
> type. Therefore, '1 << foo' (when foo is a 64 bit int) should always
> raise 1 to 64 bits.
Incorrect. "Integral promotions" are performed on the operands
of a shift; "arithmetic promotions" are not. The two arguments
are not promoted to a common type. The result type is the same
as the type of the promoted left operand. In your example, int.
r~