[tex-k] Arithmetic overflow exception with METAFONT
Jonathan Kew
jfkthame at gmail.com
Tue Oct 6 12:19:01 CEST 2020
On 06/10/2020 10:44, Wolfgang Helbig wrote:
> Hi,
>
> the FPC compiler/runtime was the culprit. See issue
> https://bugs.freepascal.org/view.php?id=37875
> The overflow is thrown in procedure edge_prep, module 329. Here is the
> statement from mf.p:
> IF NOT(ABS(INT(MEM[CUREDGES+2].HH.LH+MEM[CUREDGES+3].HH.LH-8192))<4096)
>
I haven't tried FPC, but I wonder if it would work better to cast each
of the operands to int individually, rather than casting the result of
the expression (by which time unsigned arithmetic overflow may have
already happened). So in your example from the issue, instead of:
if abs(int(a+b-8192)) < 4096 then writeln('ok');
what happens if you try:
if abs(int(a)+int(b)-8192) < 4096 then writeln('ok');
JK
> The int type cast is needed because of another error in the FPC
> compiler. (issue 37876)
>
> But otherwise, I am quite satisfied with the Free Pascal Compiler.
>
> Thanks for your replies,
> Wolfgang
>
>
> Am 05.10.20 um 23:15 schrieb Karl Berry:
>> Hi Wolfgang,
>>
>> Italic letter fAn unhandled exception occurred at
>> $000000010BF51D3E:
>>
>> As far as I can see, you'll have to run it under a debugger and see
>> what's happening. I can't divine anything from "unhandled exception".
>>
>> It is not all that likely, but certainly possible that mf is triggering
>> a compiler bug. It has happened many times in the past. You could try
>> compiling without any optimization (if you aren't already) to reduce
>> the chance of that. --best, karl.
>
More information about the tex-k
mailing list.