Modulus operator ignores sign when right-hand-side is const

These bugs do plan to be resolved, when they can be.

Moderator: GZDoom Developers

Modulus operator ignores sign when right-hand-side is const

Postby RicardoLuis0 » Thu Sep 30, 2021 12:11 pm

The Modulus operator in zscript (%) ignores the sign of the left-hand-side operand when the right-hand-side operand is a constant, performing a signed modulus operation even when it should perform an unsigned one.

Example: <uint larger than INT_MAX>%constant will be negative, while <uint larger than INT_MAX>%<another uint> will not
RicardoLuis0
 
Joined: 21 Aug 2018
Location: Brazil
Discord: RicardoLuis0#1862
Github ID: RicardoLuis0
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)

Re: Modulus operator ignores sign when right-hand-side is co

Postby Graf Zahl » Sun Oct 03, 2021 2:30 am

Hm. I fear there isn't much I can do now - the problem is so deep in the parser, filtering up several levels from there causing follow-up issues with insufficient type checks, that trying to change it will surely break more things than fix.

The biggest obstacle is that from the token scanner up to the evaluation stage it uses 32 bit constants, but screws up the constant type at the very lowest level already. And it's not just ZScript depending on this but all parsing code in the entire engine.

This entire code will have to be redesigned for 64 bit throughout to avoid these problems, but that's a major task of refactoring.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to On Hold Bugs

Who is online

Users browsing this forum: No registered users and 0 guests