|
This is actually an undefined case, so it's implementation dependent (though this may depend on the standard being used - I'm not completely sure).
0xABCD has a decimal value of 43981, which exceeds the maximum value possible in an 8-bit (single byte) char (usually -128 to +127, or 0 to 255). Generally, in type overflow problems such as this, the number either gets (repeatedly) wrapped around starting at the smallest possible value of a char, or the number gets assigned some implementation-specific value, such as MAX_CHAR.
However, the bigger issue here is that whether a char is signed or unsigned by default is also implementation dependent. So even if there was a standard way of handling overflow in the char datatype, you still can't know what the value is a priori, because the minimum/maximum value for a char (without explicit signing) is implementation dependent.
In short, throw your statements in a main() function with an output call, compile it, and see for yourself on the target machine. If you're distributing source instead of compiled executables, then you can't rely on consistent behavior from implementation-dependent cases.
*(edit - gcc 3.4.2 on windows wraps overflowed chars, and the default char signing is unsigned)
This post has been edited by jjhaag: 23 Nov, 2007 - 07:04 PM
|