This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
off-by-one bug in warning system
- To: gcc-bugs at gcc dot gnu dot org
- Subject: off-by-one bug in warning system
- From: Chris Uzdavinis <chris at atdesk dot com>
- Date: 14 Aug 2000 11:03:11 -0400
- Organization: Automated Trading Desk, Inc.
The g++ (C++) compiler 2.96 20000722 (experimental) as well as 2.95.2
have an off-by-one bug in the warning generation for the most negative
long long value.
I was defining my own LONG64_MIN value like this:
typedef long long LONG64;
const LONG64 LONG64_MIN = -9223372036854775808LL;
which generates this:
warning: decimal integer constant is so large that it is unsigned
However, the above constant is the correct (signed) value. To get rid of the
warning, I changed the declaration to this:
const LONG64 LONG64_MIN = -9223372036854775807LL - 1;
... and the warning went away. (But I shouldn't have to do that, I
think.)
--
Chris