RE:CINT and switch

Masaharu Goto (MXJ02154@nifty.ne.jp)
Fri, 04 Sep 1998 23:23:00 +0900


Glenn,

Thanks for reporting a bug. I fixed this.

Masaharu Goto

-----------------------------------------------
CINT apparently promotes case constants within
a switch statement to unsigned integers. For
example,

void stest(Int_t a)
{
switch(a) {
case 1:
printf("%d=+1\n",a);
break;
case -1:
printf("%d=-1\n",a);
break;
default:
printf("Unknown %d\n",a);
break;
}
}

root [9] stest(1)
1=+1
root [10] stest(-1)
Unknown -1
root [11] stest(0)
0=-1

As far as I know, C/C++ allow case constants
to be any integer, not just unsigned integers.
Or, at least, CINT ought not to covert

case -1: ---> case 0:

but intead flag this as an error.

Glenn