This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: signed/unsigned right shift
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: Christian Groessler <cpg at aladdin dot de>
- Cc: GCC List <gcc at gcc dot gnu dot org>
- Date: 14 Mar 2004 13:23:18 -0500
- Subject: Re: signed/unsigned right shift
- References: <87vfl7s3lf.fsf@aladdin.de>
Christian Groessler <cpg@aladdin.de> writes:
> >Correct, the multiplication is done as signed int. And it is
> >implementation
> >defined whether right shift of a negative signed int does sign fill or
> >not.
> >So both compilers are right; it is only your code that's wrong.
> >
> >C89 references: 3.3.7, 3.2.1.5, 3.2.1.1.
>
> Hmm, unfortunately I don't have the c89 standard document. Can
> somebody point me to the equvalent sections in c99?
Usual arithmetic conversions performed on operands of multiplication:
6.5.5.
Usual arithmetic conversions: 6.3.1.8. Note in particular "the
integer promotions are performed on both operands."
Integer promotions: 6.3.1.1.
Right shift of signed negative value implementation defined: 6.5.7.
Ian