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


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugd...@yahoo.com.au
           Severity|normal                      |major


--- Comment #5 from Don <clugd...@yahoo.com.au> 2010-09-18 11:43:17 PDT ---
(In reply to comment #3)
> http://www.digitalmars.com/d/1.0/expression.html#ShiftExpression
> "It's illegal to shift by more bits than the size of the quantity being
> shifted:
> 
> int c;
> c << 33;    // error"
> 
> However, there's a real problem with that spec: what if the number of bits to
> shift by isn't known at compile time?

That may be solvable with range propagation. Make it an error if it's not known
to be less than 32. It'd be painful to completely implement that rule right
now, but perhaps not later on when range propagation becomes more capable. We
could at least make it an error if the range of the expression doesn't include
ANY values in the legal range, and that would cover this test case.
I suspect that shifts by runtime-determined numbers of bits are relatively rare
-- and my experience is that they're quite bug-prone.

Raising priority to major, since this is a nasty trap.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to