This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
RE: C/C++ Bug (shifting chars.)
- To: osv at javad dot ru
- Subject: RE: C/C++ Bug (shifting chars.)
- From: grahams at rcp dot co dot uk
- Date: Tue, 21 Jul 1998 15:38:28 GMT
- CC: egcs-bugs at cygnus dot com
CC: egcs-bugs@cygnus.com
Sergei,
egcs and gcc are giving the correct results 7f and ffffffff
The calculation of c1 and c2 are NOT equivalent.
The calculation of c1 is evaluated as
char c1 = (char)((((int)c) << 3) >> 3);
The calculation of c2 is evaluated as
char c2 = (char)(((int)((char)(((int)c) << 3))) >> 3)
The difference is the truncation of the intermediate
result and subsequent sign extension.
Graham