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: "Richard Henderson" <rth at redhat dot com>
- Subject: RE: bit shift bug with GCC 2.95.2 19991024 under Solaris 7
- From: "Andrew Trotman" <andrew at ncbi dot nlm dot nih dot gov>
- Date: Tue, 9 Jan 2001 12:23:31 -0500
- Cc: <gcc-bugs at gcc dot gnu dot org>
>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.
>
You are correct, I have misread the standard. I notice that bit shifts are
the only operators this applies to.
Thanks
Andrew.