[ZScript] Prefix increment and decrement are broken

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

[ZScript] Prefix increment and decrement are broken

Post by phantombeta »

The prefix increment and decrement operators (++x and --x) are broken.
Summon "TestActor" while running GZDoom with the example WAD to test it.
Attachments
BrokenOperator.pk3
(248 Bytes) Downloaded 24 times
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: [ZScript] Prefix increment and decrement are broken

Post by _mental_ »

Prefix operators abort VM execution only if they are used directly in string format functions. I would say this is not implemented rather than broken.
From topic's title it seems that they don't work at all.
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: [ZScript] Prefix increment and decrement are broken

Post by phantombeta »

It isn't just "only if they are used directly in string format functions"

Code: Select all

version "3.2"

class TestActor : Actor {
    states {
    Spawn:
        TNT1 A 1;
        TNT1 A 1 {
            int i = 15;
            Console.Printf ("i: %d", lol (++i));
        }
        stop;
    }

    int lol (int a) { return a; }
}
This doesn't work either. Should print 16, but prints a number that changes every time you start the game.
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: [ZScript] Prefix increment and decrement are broken

Post by Marisa the Magician »

I guess we can say that vararg functions are kinda wonky then.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [ZScript] Prefix increment and decrement are broken

Post by Graf Zahl »

No not varargs. It was preincrementing a local variable and passing the result as a function parameter that caused the bug.
Post Reply

Return to “Closed Bugs [GZDoom]”