This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: signed/unsigned right shift


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


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