Bug 1601 – shr and shl error message is missing line numbers
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-10-20T03:02:00Z
Last change time
2014-02-24T15:31:10Z
Keywords
diagnostic, patch
Assigned to
bugzilla
Creator
braddr
Comments
Comment #0 by braddr — 2007-10-20T03:02:00Z
Continued from bug 550, the error for out of range shifting is present now, but lacks line numbers for Shl and Shr, but ShrAssign and ShlAssign are in good shape. The test code:
void main()
{
int i = 0;
i >>= 33;
i <<= 33;
i = i >> 33;
i = i << 33;
}
the results:
/home/braddr/sandbox/d/bugs/550/bug550.d(5): Error: shift assign by 33 is outside the range 0..32
/home/braddr/sandbox/d/bugs/550/bug550.d(6): Error: shift assign by 33 is outside the range 0..32
Error: shift by 33 is outside the range 0..32
Comment #1 by matti.niemenmaa+dbugzilla — 2007-10-20T03:32:16Z
Don't forget about UShr:
void main() {
int i;
i >>= 33;
i <<= 33;
i >>>= 33;
i = i >> 33;
i = i << 33;
i = i >>> 33;
}
Comment #2 by braddr — 2007-10-20T05:13:49Z
The fix (tested with gdc which exhibits exactly the same bug):
--- optimize.c 2007-10-20 03:11:39.000000000 -0700
+++ optimize.c.orig 2007-10-20 03:12:10.000000000 -0700
@@ -473,7 +473,7 @@
integer_t i2 = e->e2->toInteger();
d_uns64 sz = e->e1->type->size() * 8;
if (i2 < 0 || i2 > sz)
- { e->error("shift by %jd is outside the range 0..%zu", i2, sz);
+ { error("shift by %jd is outside the range 0..%zu", i2, sz);
e->e2 = new IntegerExp(0);
}
if (e->e1->isConst() == 1)
The new ouput, with Matti's version of the code:
bug550.d:4: Error: shift assign by 33 is outside the range 0..32
bug550.d:5: Error: shift assign by 33 is outside the range 0..32
bug550.d:6: Error: shift assign by 33 is outside the range 0..32
bug550.d:7: Error: shift left by 33 exceeds 32
bug550.d:8: Error: shift left by 33 exceeds 32
bug550.d:9: Error: shift left by 33 exceeds 32