[Info-vax] DCL Integer Overflow
Stephen Hoffman
seaohveh at hoffmanlabs.invalid
Sat Jul 1 17:00:33 EDT 2017
On 2017-07-01 18:07:01 +0000, Scott Dorsey said:
> On 6/30/2017 5:06 AM, GerMarsh wrote:
>> I know that there have been a few discussions about enhancing/replacing
>> DCL, but I wonder if someone will fix the old integer overflow which
>> has been there since the year dot...
>>
>> $ int=%x7fffffff
>> $ sho sym int
>> INT = 2147483647 Hex = 7FFFFFFF Octal = 17777777777
>> $ int=int+1
>> $ sho sym int
>> INT = -2147483648 Hex = 80000000 Octal = 20000000000
>
> This is not a bug, it's a feature.
Or as this particular case can also be known, "broken as designed."
> If you don't want it to roll over, what DO you want it to do?
In most contexts, overflows are considered bad. Yes, some programmers
do use overflows, and this particular DCL mess is completely expected
and normal.
> Halt with an error?
Usually trigger a warning. In classic OpenVMS, it'd be another option
on the ON statement. Even better, detect and flag that the error can
even arise as far ahead of run-time as possible. Less surprises that
way. Alas, DCL is not good at that sort of thing, though.
...Even C is starting to deal decently with these cases, too.
--
Pure Personal Opinion | HoffmanLabs LLC
More information about the Info-vax
mailing list