[Gambas-user] Possible error when doing math on bytes

Benoit Minisini benoit.minisini at gambas-basic.org
Wed Jan 4 02:17:38 CET 2023


Le 04/01/2023 à 00:16, Brian G a écrit :
> for the last 5 or 6 years we could depend on this, So many of my code in 
> many applications is now broken.
> like expecting adding one to 255 to wrap to zero etc...
> This is normal behavior for unsigned numbers.

Actually it's not. All CPU I know behave like this, but the C standard 
explicitely says that overflow leads to undefined results. Nobody must 
rely on that.

I had five places in all Gambas code I wrote (for my job and for Gambas) 
that incorrectly used overflow. It took a few minutes to fix all of them.

I don't understand how you can rely so heavily on overflow with bytes...

> 
> I am going to have to waste months fixing and checking production 
> applications.
> 
> For me this is almost enough reason to stop using gambas altogether.
> 
> I am extremely, extremely upset.... we are talking real production software
> It all has to be reevaluated and tested this is man months of testing and
> I just can not afford nor can my clients afford such expense.
> 
> This is a very bad thing.
> 
> Can an option be added to just turn this off, please, begging, go back 
> to old behaviors

I won't go back the old behaviour which is incorrect by the definition 
of the C standard, and lead to a lot of invisible bugs and security 
breach in software.

I will think about how I can add an option for allowing the old 
incorrect behaviour, but after the release of Gambas 3.18.0. At the 
moment I don't know how I can do that.

You will have to wait a little before using Gambas 3.18 in production.

Sorry for the inconvenience.

-- 
Benoît Minisini.



More information about the User mailing list