P
Peter
As stated in 2003 standard:
"An rvalue of type char, signed char, unsigned char, short int, or
unsigned short
int can be converted to an rvalue of type int if int can represent all
the values of the source type; otherwise,
the source rvalue can be converted to an rvalue of type unsigned
int.".
When does the final part of the above rule apply? Since int is at
least as wide as all types listed above, I can't imagine a value which
could be represented in one of those types, but not in int type. I
haven't found an appropriate example in any book I've read so far. Can
you please give me an example showing that the above rule is not
redundant and there in fact are cases where conversion to int would be
wrong and conversion to unsigned int must be applied instead?
"An rvalue of type char, signed char, unsigned char, short int, or
unsigned short
int can be converted to an rvalue of type int if int can represent all
the values of the source type; otherwise,
the source rvalue can be converted to an rvalue of type unsigned
int.".
When does the final part of the above rule apply? Since int is at
least as wide as all types listed above, I can't imagine a value which
could be represented in one of those types, but not in int type. I
haven't found an appropriate example in any book I've read so far. Can
you please give me an example showing that the above rule is not
redundant and there in fact are cases where conversion to int would be
wrong and conversion to unsigned int must be applied instead?