RE:Problems with C++ shift operators (PR

Masaharu Goto (MXJ02154@nifty.ne.jp)
Mon, 21 Dec 1998 21:00:21 +0900


Alain,

Thank you for reporting this bug. I fixed this in cint5.13.86.

Masaharu Goto

------------------------------------------------------------
Full_Name: Alain H. NINANE
Version: 2.00/13
Hardware: COMPAQ Armada 1700- Pentium II 233
OS: Windows 95
Severity: normal
Reproducable: always
Submission from: fynulap1.fynu.ucl.ac.be (130.104.46.76)

The right shift operator (E1>>E2) do not behave with CINT as stated by C++
2nd edition standard: "The right shift is guaranteed to be logical (0-fill)
if E1 has an unsigned type or if it has a nonnegative value; otherwise the
result is implementation dependent".

The problem is illustrated by the small example:

#include <stdio.h>

int main()
{ unsigned int d1, d2;
unsigned int sd1, sd2;

d1 = 0x7f123456; sd1 = d1>>24; printf("0x%08x -> 0x%08x\n",d1,sd1);
d2 = 0x80123456; sd2 = d2>>24; printf("0x%08x -> 0x%08x\n",d2,sd2);

return 0;
}

While gcc fills correctly d2 with 0, root fills it with ffffff. This problem
was triggered when I have tried to use the swap_word() and swap_half() macros
from the Digital's sex.h header file.

Kind regards,
Alain