Bug 23173 – "Error: signed integer overflow" for compiler generated string of `long.min`

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-06-08T15:40:41Z
Last change time
2022-08-11T09:54:07Z
Keywords
pull
Assigned to
No Owner
Creator
JR

Comments

Comment #0 by zorael — 2022-06-08T15:40:41Z
Arch/Manjaro x86_64, dmd 2.100.0. void main() { mixin("long l = ", long.min, ";"); } // Error: signed integer overflow int works.
Comment #1 by dkorpel — 2022-06-15T19:24:38Z
This is not related to mixin, it's how DMD converts the number to a string: ```D pragma(msg, long(-9223372036854775808)); ``` Prints `-9223372036854775808L`, with an L suffix. The problem is, the - operator is not part of the integer literal, so it's lexing `9223372036854775808L` which doesn't fit because L denotes a signed long.
Comment #2 by dlang-bot — 2022-06-15T19:29:56Z
@dkorpel created dlang/dmd pull request #14218 "Fix Issue 23173 - "Error: signed integer overflow" for compiler gener…" fixing this issue: - Fix Issue 23173 - "Error: signed integer overflow" for compiler generated string of `long.min` https://github.com/dlang/dmd/pull/14218
Comment #3 by dkorpel — 2022-08-11T09:54:07Z
The bot didn't close this for some reason.