[Gambas-user] Should Gambas detect integer overflow?

Jussi Lahtinen jussi.lahtinen at gmail.com
Sun Dec 4 22:57:12 CET 2022


I would definitely blame the user, if they would rely on overflows on
purpose. Just use mod etc if you need something like that.


Jussi

On Sun, Dec 4, 2022 at 9:34 PM Benoit Minisini <
benoit.minisini at gambas-basic.org> wrote:

> Hi again,
>
> The 'gcc' compiler allows Gambas to detect integer overflows when doing
> integer arithmetic with a very light penalty.
>
> Alas the other compiler, 'clang', does not support that.
>
> But I guess 'clang' will certainly gain a similar feature in the future,
> if 'gcc' has it.
>
> So, I wonder if Gambas should raise an error if an integer overflow is
> detected (when doing an integer +, - or *)?
>
> Note that the change is not backward compatible for program that
> explicitly rely on the undefined behaviour of overflow arithmetic in C.
> Which is not a good idea anyway...
>
> What do you think?
>
> --
> Benoît Minisini.
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20221204/94a2c32e/attachment.htm>


More information about the User mailing list