Bug: Postincrement in script may be executed twice

Reproduction script:

struct IntList
{
    int count;
    int items[1000];
};

local IntList gMyList;

void List_Add(IntList& this_, int value)
{
    this_.items[this_.count++] = value;
}

List_Add(gMyList, 5);

Printf("Count = %d, item 0 = %d\n", gMyList.count, gMyList.items[0]);

The expected message is of course “Count = 1, item 0 = 5”. However, in 010 Editor 16.0.2 we instead see “Count = 2, item 0 = 0”. The count++ was executed an additional time, and the value was written to index 1.

The bug can be avoided by running the increment as a separate statement:

this_.items[this_.count] = value;
this_.count++;

Can you check if this update fixes the issue: http://download.sweetscape.com/010EditorWin64Installer16.0.2c.exe This is a bug but it only happens in a fairly specific set of circumstances.

Graeme
SweetScape Software

Yes, that fixes it. Thank you!