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

Brian G brian at westwoodsvcs.com
Wed Jan 4 00:16:31 CET 2023

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. 

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 

"Failure is the key to success; 
each mistake teaches us something" .. Morihei Ueshiba 
Brian G 

----- On Jan 3, 2023, at 2:51 PM, Jussi Lahtinen <jussi.lahtinen at gmail.com> wrote: 

Why do you use bytes in that code? You cannot trust in that approach anyway. 


On Wed, Jan 4, 2023 at 12:48 AM Brian G < [ mailto:brian at westwoodsvcs.com | brian at westwoodsvcs.com ] > wrote: 

A lot of my applications no longer run, 

And bad new, it reports error even if fast unsafe in my apps 

How do i just turn this off permanently, It is very bad news! 

"Failure is the key to success; 
each mistake teaches us something" .. Morihei Ueshiba 
Brian G 

----- On Jan 3, 2023, at 2:40 PM, Benoit Minisini [ mailto:benoit.minisini at gambas-basic.org | benoit.minisini at gambas-basic.org ] wrote: 

> Le 03/01/2023 à 23:08, Brian G a écrit : 
>> When I do math on bytes I get an overflow now when the value of the 
>> byte goes negative 
>> example: 
>> dim a as byte = 0 
>> dim b as byte = 24 
>> dim result as byte = a - b 
>> This causes an overflow error, where in the past it was just a negative 
>> number. 
>> Is this a bug or a new undocumented feature? 
> Overflows were ignored before, as it is usually the case in C programs, 
> even if the behaviour of overflows is unspecified. It's for speed 
> reasons, or to make hacking easier, I dunno. 
> So I decided to detect them, for a small performance penalty. 
> The overflow checks are only disabled on 'Fast Unsafe' functions. 
> Regards, 
> -- 
> Benoît Minisini. 
> ----[ [ http://gambaswiki.org/wiki/doc/netiquette | http://gambaswiki.org/wiki/doc/netiquette ] ]---- 

----[ [ http://gambaswiki.org/wiki/doc/netiquette | http://gambaswiki.org/wiki/doc/netiquette ] ]---- 

----[ http://gambaswiki.org/wiki/doc/netiquette ]---- 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230103/3ed84f51/attachment-0001.htm>

More information about the User mailing list