This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

off-by-one bug in warning system



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]