Thread overview |
---|
November 18, 2006 [Issue 550] New: Shifting by more bits than size of quantity is allowed | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=550 Summary: Shifting by more bits than size of quantity is allowed Product: D Version: 0.174 Platform: PC URL: http://www.digitalmars.com/d/expression.html OS/Version: Windows Status: NEW Keywords: spec Severity: normal Priority: P4 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: deewiant@gmail.com OtherBugsDependingO 511 nThis: The compiler allows the following code, directly from the spec: int c; c << 33; // error Even though "[i]t's illegal to shift by more bits than the size of the quantity being shifted". I'm not sure if this is a useful restriction, but either the spec or DMD is in error. -- |
November 18, 2006 [Issue 550] Shifting by more bits than size of quantity is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=550 smjg@iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg@iname.com Keywords| |accepts-invalid ------- Comment #1 from smjg@iname.com 2006-11-18 07:02 ------- If the right operand is a variable, it probably makes more sense from an efficiency POV to allow it. If it's a compile-time constant, the compiler could easily catch the error. However, I'm beginning to think such a restriction may interfere with generic programming. -- |
December 03, 2006 [Issue 550] Shifting by more bits than size of quantity is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=550 deewiant@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P4 |P3 ------- Comment #2 from deewiant@gmail.com 2006-12-03 03:36 ------- Only partially fixed in DMD 0.176. Stepping up the priority since compiler behaviour is now inconsistent. void main() { int c; c = c << 33; // Error: shift left by 33 exceeds 32 } void main() { int c; c = c >> 33; // Works, shouldn't } void main() { int c; c <<= 33; // Works, shouldn't } void main() { int c; c >>= 33; // Works, shouldn't } void main() { int c; c = c >>> 33; // Works, shouldn't } void main() { int c; c >>>= 33; // Works, shouldn't } Also, this error message seems a bit strange: void main() { int c; c = c << -1; // Error: shift left by -1 exceeds 32 } -- |
May 12, 2007 [Issue 550] Shifting by more bits than size of quantity is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=550 ------- Comment #3 from deewiant@gmail.com 2007-05-12 03:04 ------- Though the spec doesn't say it, it might as well be worth also disallowing shifts equal to the size of the quantity, as they just zero the value. Or, at least, they should: some appear to be no-ops currently. As pointed out by Thomas Kühne in digitalmars.D.learn ( http://lists.puremagic.com/pipermail/digitalmars-d-learn/2007-May/005040.html ), compile-time shifts should be done by ((shift >= x.sizeof * 8) ? 0 : shift) instead of the current (shift % (x.sizeof * 8)). -- |
October 05, 2007 [Issue 550] Shifting by more bits than size of quantity is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=550 matti.niemenmaa+dbugzilla@iki.fi changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic ------- Comment #4 from matti.niemenmaa+dbugzilla@iki.fi 2007-10-05 14:29 ------- DMD 1.022 fixes the issues, but the error messages for the shift expressions (e.g. c = c << 33) don't have file and line number info. The assignments (c <<= 33) do, though. -- |
October 20, 2007 [Issue 550] Shifting by more bits than size of quantity is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=550 braddr@puremagic.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #5 from braddr@puremagic.com 2007-10-20 03:05 ------- Per Walter's request, moving the new problem (missing line numbers) into a new bug. This one has been addressed. A little counter intuitively, the source of the two issues is probably not actually related to the same part of the code. -- |
Copyright © 1999-2021 by the D Language Foundation