[4190] in Athena Bugs
saber in ANSI mode and large negative integral constants
daemon@ATHENA.MIT.EDU (Ken Raeburn)
Mon Feb 12 05:34:21 1990
Date: Mon, 12 Feb 90 05:34:04 -0500
From: Ken Raeburn <Raeburn@ATHENA.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
Cc: jtkohl@ATHENA.MIT.EDU
When saber is in ANSI mode, it doesn't like this constant, complaining
that it's too big; somehow it seems to have forgotten the leading minus sign:
"/afs/athena.mit.edu/astaff/project/krb5/src/include/krb5/wordsize.h":40, Decimal constant too large (Warning #221)
39: #define KRB5_INT32_MAX 2147483647
40: #define KRB5_INT32_MIN (-2147483648)
^
41:
Decimal constant (2147483648) exceeds maximum signed long (2147483647).
Actually, odd though may this sound, the error in this case isn't the
one John named.
From what I read in my (slightly outdated) dpANS-C, in this example,
"-2147483648" is not an literal integer constant. Rather, it is an
expression, with the unary negation operator applied to the value
"2147483648", which (because it exceeds the range of "signed long")
must be of type "unsigned long".
(I'm not entirely certain of this, but I haven't found anything yet --
though I'm still looking -- that says that -2147483648 doesn't have
unsigned type.)
From what I recall seeing recently in other places, I think the
correct way to defined KRB5_INT32_MIN above is:
#define KRB5_INT32_MIN (-KRB5_INT32_MAX-1)
Saber does appear to miss the conversion to unsigned:
1 -> 2147483648;
Warning #221: Decimal constant (2147483648) exceeds maximum signed long (2147483647).
(int) 2147483647
2 ->
(this is 2.1 on the RT) but I'm not sure the result of this isn't
related to the problem reading numbers with the high bit set.
-- Ken