From: Bernhard H. <ber...@be...> - 2002-02-14 16:10:28
|
> Signedness of "char" is implementation defined , hence 0xff can be > treated as 256 & -1 depending on the implementation and both are correct > no code should rely on this. 255 & -1. I fully agree with the rest. But what behaviour do you recommend for: signed char sc; unsigned char uc; char *cp; void foo (void) { cp += sc; // sign/zero extension? cp += uc; // sign/zero extension? } Bernhard > > Sandeep > > > -----Original Message----- > > From: Bernhard Held [mailto:ber...@be...] > > Sent: Wednesday, February 13, 2002 11:08 PM > > To: Sandeep Dutta; 'Johan Knol'; sdc...@li... > > Subject: Re: [sdcc-devel] pointer arithmatic unsigned? > > > > > > > No .. pointer arithmetic is always unsigned .. > > > sandeep > > No, sorry, no, this can't be true. It must be possible to decrement a > > pointer with a signed char or short. I've tested several > > compilers. All of > > them perform a sign extension with signed integers. > > > > > > char c; > > > > char *cp; > > > > > > > > void foo (void) { > > > > cp += c; > > > > } > > > > > > > > > > > > Should c be sign-extended before being added to cp? > > > > signed char c; sign extension > > unsigned char c; zero extension > > > > Bernhard > > > > > > > > _______________________________________________ > sdcc-devel mailing list > sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-devel > > |