Bug 230 – long.min cannot be parsed

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2006-06-28T17:35:00Z
Last change time
2014-02-15T13:19:16Z
Assigned to
bugzilla
Creator
benoit

Comments

Comment #0 by benoit — 2006-06-28T17:35:40Z
void main(){ assert( +9223372036854775807L == long.max ); assert( -9223372036854775807L == long.min ); assert( -9223372036854775808L == long.min ); // signed integer overflow }
Comment #1 by shro8822 — 2006-06-28T17:49:19Z
Quoting the speck (lex.html) Decimal Literal, L Suffix Type 0L .. 9223372036854775807L long -(9223372036854775808L) is invalid b/c it is parsed as "- intLiteral" Bug is not in DMD. OTOH: should it be?
Comment #2 by benoit — 2006-06-28T18:27:50Z
Seems to be according to the spec. But for me it is not logic that I can write 0x8000_0000_0000_0000L but not -9223372036854775808L.
Comment #3 by bugzilla — 2006-07-08T16:36:51Z
The compiler is behaving correctly. The - is applied after the numeric literal is processed, and 9223372036854775808L is out of range.