[M3devel] overshifting?
Tony Hosking
hosking at cs.purdue.edu
Tue Mar 2 20:44:21 CET 2010
Actually, I should have noticed. Word.LeftShift and Word.RightShift both check the range of the shift parameter. It's not the shift that is out of range. It is the shift constant (in this case 630). If you try Shift(FIRST(LONGINT), -630) you get 0 as expected.
So, in fact the run-time error is correct! 630 is not in the range [0..63].
On 2 Mar 2010, at 13:54, Tony Hosking wrote:
> I'm trying to understand this. Surely shifting right will never be out of range? Looks like something is broken.
>
> On 2 Mar 2010, at 09:04, Jay K wrote:
>
>> PutLH(Long.RightShift(FIRST(LONGINT), 630)); PutT("\n");
>>
>>
>> I'm guessing the warning is all you're supposed to get here?
>>
>>
>> C:\dev2\cm3.2\m3-sys\m3tests\src\p2\p227>cm3
>> --- building in NT386 ---
>> new source -> compiling Main.m3
>> "..\Main.m3", line 894: warning: value out of range
>>
>> ***
>> *** runtime error:
>> *** An enumeration or subrange value was out of range.
>> *** file "..\src\TWordN.m3", line 129
>> ***
>> Stack trace:
>> FP PC Procedure
>> --------- --------- -------------------------------
>> 0x12f0dc 0x48791a RightShift + 0x35 in ..\src\TWordN.m3
>> 0x12f15c 0x47c62f doshift + 0x2c6 in ..\src\Stackx86.m3
>> 0x12f188 0x4485d2 shift_right + 0x1b2 in ..\src\M3x86.m3
>> 0x12f1ac 0x6414ed shift_right + 0xf5 in ..\src\M3CG_Check.m3
>> 0x12f1d4 0x505a4f Shift_right + 0x87 in ..\src\misc\CG.m3
>> 0x12f1f8 0x570641 CompileR + 0x1da in ..\NT386\LongShift.m3 => ..\src\builti
>> nWord\Shift.mg
>> 0x12f218 0x5cec2f Compile + 0x83 in ..\src\exprs\CallExpr.m3
>> 0x12f234 0x5bfee4 Compile + 0x53 in ..\src\exprs\Expr.m3
>> 0x12f274 0x5d19a7 EmitChecks + 0xdf in ..\src\exprs\CheckExpr.m3
>> 0x12f2b4 0x5c8b15 GenOrdinal + 0xa6 in ..\src\values\Formal.m3
>> ......... ......... ... more frames ...
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100302/f3a88cb1/attachment-0002.html>
More information about the M3devel
mailing list