This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: bit shift bug with GCC 2.95.2 19991024 under Solaris 7


>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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]