off-by-one bug in warning system
Alexandre Oliva
aoliva@redhat.com
Mon Aug 14 12:49:00 GMT 2000
On Aug 14, 2000, Chris Uzdavinis <chris@atdesk.com> wrote:
> 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.
No. There's no such thing as a negative literal.
> typedef long long LONG64;
> const LONG64 LONG64_MIN = -9223372036854775808LL;
`-...8LL' must be parsed as two separate tokens, according to the C
and C++ Standards: a unary minus and an integer literal that is too
large to fit in a `long long'. Thus the warning.
> const LONG64 LONG64_MIN = -9223372036854775807LL - 1;
> ... and the warning went away. (But I shouldn't have to do that, I
> think.)
Yes, you should.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me
More information about the Gcc-bugs
mailing list