Topic: casting signed char to unsigned char? (Was: Promotes in C - not in C++)


Author: joe@bftsi0.UUCP (Joe Foster of Borg)
Date: 21 Aug 93 04:46:16 GMT
Raw View
In article <1993Aug19.182054.16053@razor.genasys.com>, mikla@razor.genasys.com (Michael Aichlmayr) writes:

[discussion about compiler errors resulting from casting char* to
far unsigned char * deleted]

> > That "far" stuff is MS-specific and is not part of C++.

>  You can look at the error by ignoring 'far', it's really not relevant
> to the problem.

Casting from a far pointer to a near pointer is a big deal,
however, since information is lost. However, casting from a
pointer to a far pointer shouldn't be a problem.

> >The problem may be due to promotion from char to unsigned char or
> >from char* to char far*. Who knows? I'd report it to MS, if I were you.

>  I think you hit the nail on the head. What that error really means is
> (I've run into it before) "cannot promote 'signed char' to
> 'unsigned char'".  Now why *that* is the case, I can't say for sure,
> it seems that 'signed char' should be promotable to 'unsigned char'.
> I might expect a warning, but not an error.

Ditto! Isn't it the case that on some machines, char defaults to
unsigned? And that on some other machines, using unsigned chars
involves a large performance hit for some reason? In this light,
not allowing conversions between signed and unsigned chars makes
about as much sense as disallowing conversions between signed and
unsigned ints, or between ints and longs, since those conversions
are more expensive to implement?

I'm crossposting this to comp.std.c++. Perhaps the people there can
shed some light on this.

Joe Foster
joe@bftsi0.uucp