[Issue 1773] excessively long integer literal

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Feb 23 05:35:06 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1773


aplee at primus.ca changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




------- Comment #5 from aplee at primus.ca  2008-02-23 07:35 -------
$ cat t.d
ulong v1 = 0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF;
ulong v2 = 0x1_0000_0000_0000_0000;
ulong v3 = 0x1_FFFF_FFFF_FFFF_FFFF;
ulong v4 = 0x7_FFFF_FFFF_FFFF_FFFF;
ulong v5 = 0x1_0000_FFFF_FFFF_FFFF;
void main() {}
$ ./dmd t.d
t.d(1): integer overflow
t.d(2): integer overflow
t.d(5): integer overflow
$ ./dmd -v
Digital Mars D Compiler v1.026

v3 and v4 are also overflows but D does not see that.

The problem is that any input stream that fills in the r*n+d will all 1s is
going to be a problem. I was not able to come up with a solution different than
the one explained in the strtol.c file which can be found everywhere on the
internet, which uses a cutoff value between legal numbers and illegal numbers.


-- 



More information about the Digitalmars-d-bugs mailing list