1601 – shr and shl error message is missing line numbers

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1601 - shr and shl error message is missing line numbers
Summary: shr and shl error message is missing line numbers
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: Walter Bright
URL:
Keywords: diagnostic, patch
Depends on:
Blocks:
Reported: 2007年10月20日 03:02 UTC by Brad Roberts
Modified: 2014年02月24日 15:31 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Brad Roberts 2007年10月20日 03:02:00 UTC
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 Matti Niemenmaa 2007年10月20日 03:32:16 UTC
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 Brad Roberts 2007年10月20日 05:13:49 UTC
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
Comment 3 Don 2008年07月09日 07:12:05 UTC
Fixed DMD1.032
Comment 4 Walter Bright 2008年07月09日 22:40:11 UTC
Fixed dmd 1.032 and 2.016


AltStyle によって変換されたページ (->オリジナル) /