[Issue 13606] erroneous overflow error in negative long literal

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Nov 1 20:31:11 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13606

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement

--- Comment #8 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to hsteoh from comment #7)
> This looks like two bugs in one... the first appears to be caused by parsing
> negative literals as the negation of the corresponding positive literal, and
> the second is the implicit cast from unsigned to signed, which has been a
> source of subtle bugs in D.

Currently this is not a bug and the overflow error is expected behavior.

As hsteoh said, the negative unary operator '-' is not a part of integer
literal.

-9223372036854775808L is parsed as a unary expression of negative operator '-'
on the long literal 9223372036854775808L, and the overflowed signed literal
which is typed as long by the suffix 'L' is rejected in lexer level.

http://dlang.org/lex#integerliteral

> 0L .. 9_223_372_036_854_775_807L	long

Long integer literal is limited up to 9_223_372_036_854_775_807.

To allow the code, we need to update spec to support "negative integer
literal".

Change the importance to enhancement.

--


More information about the Digitalmars-d-bugs mailing list