[Issue 1773] excessively long integer literal
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 17 20:14:34 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1773
------- Comment #3 from aplee at primus.ca 2008-01-17 22:14 -------
I have been able to characterize the problem further by running a piece of the
lexer as a standalone C program:
#include <stdio.h>
#include <stdint.h>
void main() {
int cnt = 17;
uint64_t n;
int r = 16, d;
printf("Walter's parsing 0xF_FFFF_FFFF_FFFF_FFFF\n");
n = 0;
cnt = 17;
while(cnt--) {
d = 15; // 0xF_FFFF_FFFF_FFFF_FFFF;
if (d >= r) break;
printf("Condition value %llu < %llu\n",n * r + d,n);
if (n * r + d < n) {
printf("Overflow\n");
break;
}
n = n * r + d;
printf("%0d: n = %llu\n",cnt,n);
}
printf("Walter's parsing 0x1_0000_0000_0000_0000\n");
n = 0;
cnt = 17;
while(cnt--) {
if (cnt == 16) d = 1; // 0x1_0000_0000_0000_0000;
else d = 0;
if (d >= r) break;
printf("Condition value %llu < %llu\n",n * r + d,n);
if (n * r + d < n) {
printf("Overflow\n");
break;
}
n = n * r + d;
printf("%0d: n = %llu\n",cnt,n);
}
}
In running this program which mimics the parsing of the two integer literals
shown above, the problem becomes obvious. It is in the conditional. I do not
know the solution yet.
--
More information about the Digitalmars-d-bugs
mailing list